January 2020
Intermediate to advanced
548 pages
13h 36m
English
The if statement is composed of the if keyword followed by a parenthesized expression and then an additional statement:
if (ConditionExpression) Statement
ConditionExpression can be of limitless complexity as long as it is truly an expression:
if (true) {}if (1 || 2 || 3) {}if ([1, 2, 3].filter(n => n > 2).length > 0) {}
The statement following the parenthesized expression can be a single-line statement or a block and designates the code that should be run if the ConditionExpression evaluates to a truthy value:
// These are equivalentif (true) { doBaz(); }if (true) doBaz();
The value you pass as ConditionExpression is compared to a Boolean to determine its truthiness. We've already been aptly introduced to the concepts of ...
Read now
Unlock full access