Skip to content

JavaScript Syntax and Variables#

JavaScript Keywords#

Keyword/Reserved Word Description
abstract Reserved for future use. It was originally intended for defining abstract methods.
arguments Refers to an array-like object that contains the arguments passed to a function.
await Pauses the execution of an async function until a Promise is resolved or rejected.
boolean A primitive data type representing a logical value: true or false.
break Terminates the current loop or switch statement.
byte Reserved for future use. It was intended for working with binary data.
case Defines a case in a switch statement.
catch Catches and handles exceptions in a try-catch block.
char Reserved for future use. It was intended for working with character data.
class Defines a class in JavaScript (introduced in ECMAScript 2015).
const Declares a block-scoped constant variable.
continue Skips the current iteration of a loop.
debugger Stops the execution of JavaScript and invokes the debugger.
default Specifies the default case in a switch statement.
delete Deletes a property from an object.
do Executes a block of code until a condition is false.
double Reserved for future use. It was intended for working with floating-point numbers.
else Executes a block of code if the condition is false (used with if statements).
enum Reserved for future use. It was intended for creating enumerations.
eval Evaluates a string as JavaScript code.
export Exports functions, objects, or values from a module.
extends Inherits properties and methods from a parent class (used with class declarations).
false A Boolean value representing false.
final Reserved for future use. It was intended for preventing inheritance or overriding.
finally Specifies a block of code to be executed after a try block, regardless of an exception.
float Reserved for future use. It was intended for working with floating-point numbers.
for Executes a block of code for a specified number of times.
function Declares a function.
goto Reserved for future use. It was intended for jumping to a labeled statement.
if Executes a block of code if the condition is true.
implements Reserved for future use. It was intended for implementing interfaces.
import Imports functions, objects, or values from a module.
in Checks if a specified property is in an object.
instanceof Checks if an object is an instance of a specified class.
int Reserved for future use. It was intended for working with integers.
interface Reserved for future use. It was intended for defining interfaces.
let Declares a block-scoped local variable (introduced in ECMAScript 2015).
long Reserved for future use. It was intended for working with large integers.
native Reserved for future use. It was intended for indicating native methods.
new Creates an instance of an object.
null Represents the absence of a value or an uninitialized variable.
var Declares a javascript variable
package Reserved for future use. It was intended for organizing related classes.
private Reserved for future use. It was intended for defining private members of a class.
protected Reserved for future use. It was intended for defining protected members of a class.
public Reserved for future use. It was intended for defining public members of a class.
return Exits a function and specifies its return value.
short Reserved for future use. It was intended for working with small integers.
static Defines a static method or property for a

Variables#

  • We can declare a variable by using 3 keywords: var, let and const.
1
2
3
var message1 = "message 1";
let message2 = "message 2";
const message3 = "message 3";
  • In which, by using the var keyword the variable can be global or local scope if we define it outside a function the variable will have global scope otherwise if we define it inside a function it will be local scope.
  • ES6 provides a new way of declaring a variable by using the let keyword. The let keyword is similar to the var keyword, except that these variables are blocked-scope. In JavaScript, blocks are denoted by curly braces {} , for example, the if else, for, do while, while, try catch and so on:
  • Like the let keyword, the const keyword declares blocked-scope variables. However, the block-scoped variables declared by the const keyword can’t be reassigned.

See Also#

References#