JavaScript booleans can have one of two values: true or false.
You can use the Boolean() function to find out if an expression is true:
//Display the value of Boolean(10 > 9)
console.log( Boolean(10 > 9) );
console.log( 10 > 9 );
Property | Description |
---|---|
constructor | Returns the function that created JavaScript's Boolean prototype |
prototype | Allows you to add properties and methods to the Boolean prototype |
Method | Description |
---|---|
toString() | Converts a boolean value to a string, and returns the result |
valueOf() | Returns the primitive value of a boolean |
console.log(new Boolean(true).toString()); console.log(new Boolean(true).valueOf());