⊗jsPmCdShFCh 121 of 504 menu

Shorthand checking for false in JavaScript

Suppose now we want to check the value of the variable for false. It can be done like this:

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

You can also write the equivalent code with negation:

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

The above code can be rewritten in a shortened form as follows:

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

Rewrite the following code using the shortened form:

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

Rewrite the following code using the shortened form:

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

Rewrite the following code using the shortened form:

let test = true; if (test != false) { console.log('+++'); } else { console.log('---'); }
English
AfrikaansAzərbaycanБългарскиবাংলাБеларускаяČeštinaDanskDeutschΕλληνικάEspañolEestiSuomiFrançaisहिन्दीMagyarՀայերենIndonesiaItaliano日本語ქართულიҚазақ한국어КыргызчаLietuviųLatviešuМакедонскиMelayuမြန်မာNederlandsNorskPolskiPortuguêsRomânăРусскийසිංහලSlovenčinaSlovenščinaShqipСрпскиSrpskiSvenskaKiswahiliТоҷикӣไทยTürkmenTürkçeЎзбекOʻzbekTiếng Việt
We use cookies for website operation, analytics, and personalization. Data processing is carried out in accordance with the Privacy Policy.
accept all customize decline