JavaScript Boolean Object
Boolean is the type with only two values, true and false. Calling Boolean(value) converts any value to true or false using JavaScript's truthiness rules.
Description
The Boolean type has just two values, true and false, and is what comparisons and conditions produce. Calling Boolean(value) as a function converts any value to a boolean, which is the same as writing !!value.
The values that convert to false are called falsy: false, 0, -0, 0n, '', null, undefined and NaN. Everything else is truthy, including '0', 'false', empty arrays and empty objects. Avoid new Boolean(false): it creates an object, and every object is truthy.
Conditions in if statements, loops and the logical operators convert values to booleans automatically, so you rarely need Boolean() explicitly. A common use is array.filter(Boolean), which removes all falsy values from an array. When comparing, avoid value == true, because it converts types in surprising ways; test the value directly or compare with ===.
Creating
true
false
Boolean(value)Example
Browser Support
The following information will show you the current browser support for the Boolean object. Hover over a browser icon to see the version that first introduced support for this object.
Desktop





Tablets & Mobile





