⊗jsPmCdShTCh 120 of 504 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('---'); }
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