JavaScript Booleans
A boolean is a JavaScript data type that is either true or false.
Example:
let isTrue
=
true;
let isFalse
=
false;
JavaScript Boolean Methods
Below is a list of Boolean methods in JavaScript.
Method | Description |
---|---|
toString() | Converts Boolean into String. |
valueOf() | Returns the value of a boolean. |
Example:
// toString Method
let bool
=
new
Boolean(10);
console.log(bool.toString());
// valueOf Method
let bool
=
new
Boolean(true);
console.log(bool.valueOf());
Output:
true
true