25 of 264 menu

true value

The true value means true. It can be used in conditionals with if and elseif to test them for truth, and also with the help of true you can determine the presence of an element or property.

Syntax

true;

Example

Let's check if the array contains the letter 'a':

let arr = ['a', 'b', 'c', 'd']; console.log(arr.includes('a'));

The code execution result:

true

Example

Let's check if a value of the variable is equal to 1:

let num = 1; console.log(num === 1);

The code execution result:

true

Example

Let's check the result of the condition:

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

The code execution result:

'---'

See also

  • the false value
    that indicates that the element value is false
  • the null value
    that denotes the absence of an object or element
  • the undefined value
    that denotes that the element value is "undefined"
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