ES6 - Decision Making



A conditional/decision-making construct evaluates a condition before the instruction/s are executed.

Decision Making

Conditional constructs in JavaScript are classified in the following table.

Sr.No Statement & Description
1 if Statement

An ‘if’ statement consists of a Boolean expression followed by one or more statements .

2 if…else Statement

An ‘if’ statement can be followed by an optional ‘else’ statement, which executes when the Boolean expression is false.

3 The else.. if ladder/nested if statements

The else…if ladder is useful to test multiple conditions. Following is the syntax of the same.

4 switch…case Statement

The switch statement evaluates an expression, matches the expression’s value to a case clause and executes the statements associated with that case.

Advertisements