⊗jsPmCdShTCh 120 of 502 menu

Shorthand checking for true in JavaScript

Let's say we want to know if the variable test is equal to the value true. In this case, the construction if can be written as:

let test = true; if (test == true) { console.log('+++'); } else { console.log('---'); }

In programming, such checks are needed very often, so there is a more elegant shorthand for them: instead of if (test == true), you can simply write if (test).

Let's rewrite our code in shortened form:

let test = true; if (test) { console.log('+++'); } else { console.log('---'); }

Rewrite the following code using the shortened form:

let test = true; if (test === true) { console.log('+++'); } else { console.log('---'); }
enru