JavaScript Boolean Methods

About This Index
This page is the JavaScript Boolean Methods index for the tutorial track. Each row links to a full guide with syntax, three runnable examples, browser notes, and FAQs.
Learn what a Boolean is, how truthy and falsy values work, and why new Boolean(false) is a trap on /js/boolean. Use this page when you need one of the two methods: toString() turns true or false into text, and valueOf() unwraps a Boolean object into the plain value.
A Boolean has just two possible values, so there is little to do with it. Both methods are called on a value: true.toString(). There are no static methods such as Boolean.parse() (it is undefined). To turn text back into a Boolean, compare it: text === "true".
How to Call a Boolean Method
Both methods take no arguments. You call them with a dot on a Boolean value, or on a Boolean object:
// Both methods are called on a Boolean value (or a Boolean object)
true.toString(); // "true"
(false).toString(); // "false"
true.valueOf(); // true
new Boolean(false).valueOf(); // false
// There are no static methods such as Boolean.parse()
typeof Boolean.parse; // "undefined"
"true" === "true"; // true (how you turn text back into a Boolean) The comments show what each line gives back. Text in quotes is a string, and true or false without quotes is a real Boolean.
JavaScript Boolean Methods Table
All method guides in this JavaScript tutorial series (2 tutorials), grouped by what they do.
Convert a Boolean
2 methodsBoth are instance methods: call them on a Boolean value such as true. One turns it into text, the other unwraps a Boolean object.
| Method | Description | Tutorial |
|---|---|---|
toString() | Turn true or false into the text "true" or "false". | Open |
valueOf() | Get the plain true or false out of a Boolean object (a wrapper). | Open |
Frequently Asked Questions
Start with Boolean toString()
Turn true or false into text for a label or a query string, and learn why the text "false" is truthy.
14 people found this page helpful
