Riferimento booleano JavaScript
JavaScript booleani
I booleani JavaScript possono avere uno di due valori: true
o
false
.
La funzione booleana()
Puoi usare la Boolean()
funzione per scoprire se un'espressione è vera:
Esempio
Boolean(10 > 9)
O ancora più semplice:
Esempio
(10 > 9)
10 > 9
Per un tutorial sui booleani, leggi il nostro tutorial booleano JavaScript .
Metodi booleani JavaScript
Method | Description |
---|---|
toString() | Converts a boolean value to a string, and returns the result |
valueOf() | Returns the primitive value of a boolean |
Proprietà booleane JavaScript
Property | Description |
---|---|
constructor | Returns the function that created JavaScript's Boolean prototype |
prototype | Allows you to add properties and methods to the Boolean prototype |