Reference for JavaScript (ECMAScript 2020)

The tables below show the syntactically highlighted topic for the language.


If you see any incorrect information, please help us improve! Feel free to either create an issue or use the link at the bottom of the language column to correct any information.

 

Conditional Statements (ifs)

Concept

JavaScript's Implementation

If conditional
if (condition) {
    statements;
}
If/Else conditional
if (condition) {
    statements;
} else {
    statements;
}
If/ElseIf conditional
if (condition) {
    statements;
} else if (condition) {
    statements;
}
If/ElseIf/Else conditional
if (condition) {
    statements;
} else if (condition) {
    statements;
} else {
    statements;
}
Switch statement
switch (expression) {
  case x:
    statements;
    break;
  case y:
    statements;
    break;
  default:
    statements;
}
Expression is compared with cases using the strict === comparator
Pattern matching
Unknown
Ternary conditional
condition ? exprIfTrue : exprIfFalse
 

Loops

Concept

JavaScript's Implementation

While loop
while (condition) {
    statements;
}
Do/While loop
do {
    statements;
} while (condition);
Until loop
Not Implemented In This Language
Do/Until loop
Not Implemented In This Language
For loop
for (initialization_statement; condition; update_statement){
    statements;
}
Foreach loop
// Example 1
for(const element of array) { ... }
// Example 2
array.forEach(function(currentValue, index, arr), thisValue)
// Example 3
for(const propertyName in object) { ... }
The for...of loop is intended for arrays and provides the entire element. The for...in loop works on objects and arrays and returns the key, requiring the value to be dereferenced such as object[propertyName]. The array.forEach(...) loop is a functional iterator provided only on arrays.
Breaking out of a loop
Unknown
Continuing to the next iteration of a loop
Unknown
List Comprehension
Unknown
 

Iterations

Concept

JavaScript's Implementation

Each iteration
Not Implemented In This Language
Map iteration
array.map(function(currentValue, index, arr), thisValue)
Filter iteration
array.filter(function(currentValue, index, arr), thisValue)
Fold iteration
Not Implemented In This Language
 

Resource Management

Concept

JavaScript's Implementation

Context manager or with/using statement
Unknown
Defer statement
Unknown
 
 
Want to add or correct information for JavaScript?
or get the complete template. control_structures.json