Boolean - JavaScript | MDN

developer.mozilla.org

Tin mới

HTML: Markup language

See all HTML references

Date & time formats

See all HTML guides

CSS: Styling language

See all CSS references

See all CSS guides

Centering an element

JavaScript: Scripting language

Standard built-in objects

Expressions & operators

Statements & declarations

See all JavaScript references

Control flow & error handing

Loops and iteration

Working with objects

See all JavaScript guides

Web APIs: Programming interfaces

Service worker API

Using the Web animation API

Using the Fetch API

Working with the History API

Using the Web speech API

All web technology

Progressive web apps

Learn web development

Getting started modules

Structuring content with HTML module

CSS styling basics module

Dynamic scripting with JavaScript module

Border-image generator

Border-radius generator

Box-shadow generator

Color format converter

conditional operator

Boolean values are typically produced by relational operators, equality operators, and logical NOT (!). They can also be produced by functions that represent conditions, such as Array.isArray(). Note that binary logical

Array.prototype.filter()

Boolean values are typically produced by relational operators, equality operators, and logical NOT (!). They can also be produced by functions that represent conditions, such as Array.isArray(). Note that binary logical

Boolean primitives and Boolean objects

For converting non-boolean values to boolean, use Boolean as a function or use the double NOT operator. Do not use the Boolean() constructor with new.

Boolean primitives and Boolean objects

For converting non-boolean values to boolean, use Boolean as a function or use the double NOT operator. Do not use the Boolean() constructor with new.

convert objects to primitives

Note: Unlike other type conversions like string coercion or number coercion, boolean coercion does not attempt to convert objects to primitives by calling user methods.

Array.prototype.toString()

Many built-in operations that expect booleans first coerce their arguments to booleans. The operation can be summarized as follows:

converted to numbers

Many built-in operations that expect booleans first coerce their arguments to booleans. The operation can be summarized as follows:

Boolean.prototype.constructor

The constructor function that created the instance object. For Boolean instances, the initial value is the Boolean constructor.

Boolean.prototype.toString()

Returns a string of either true or false depending upon the value of the object. Overrides the Object.prototype.toString() method.

Object.prototype.toString()

Returns a string of either true or false depending upon the value of the object. Overrides the Object.prototype.toString() method.

Boolean.prototype.valueOf()

Returns a string of either true or false depending upon the value of the object. Overrides the Object.prototype.toString() method.

Object.prototype.valueOf()

Returns the primitive value of the Boolean object. Overrides the Object.prototype.valueOf() method.

Learn how to contribute

This page was last modified on Jul 10, 2025 by MDN contributors.

[Symbol.hasInstance]()

__defineGetter__()

__defineSetter__()