Boolean objects in JavaScript

Describe

Boolean objects represent two values, or "true" or "false". If the value parameter is ignored either 0, -0, null, false, NaN , undefined, or an empty string (""), the object has an initial value of false.

Syntax

Use the following syntax to create a Boolean object.

 var val = new Boolean ( value ); 

Boolean properties

Below is a list of Boolean object properties:

Properties Description

constructor

Returns a reference to the Boolean function that creates that object.

prototype

The prototype property allows you to add properties and methods to an object.

Boolean methods

Below is a list of methods of the Boolean object and its description:

Method Description

toSource ()

Returns a string containing the source of the Boolean object; You can use this string to create an equivalent object.

toString ()

Returns a string: either "true" or "false" depending on the value of the object.

valueOf ()

Returns giá trị Primitive của Boolean object.

According to Tutorialspoint

Previous article: Object Number in JavaScript

Next lesson: String object in JavaScript

3.5 ★ | 2 Vote

May be interested

  • String object in JavaScriptPhoto of String object in JavaScript
    the string object helps you work with a series of characters; it helps handle the original string data types in javascript with some help methods.
  • Array (Array) in JavaScriptPhoto of Array (Array) in JavaScript
    array object - array helps you store multiple values ​​in a single variable. it stores a set of fixed-size ranges of elements in the same type (type). an array is used to store a data set, but it is often more useful to think of an array as a collection of variables in the same type.
  • Date object in JavaScriptPhoto of Date object in JavaScript
    date object is a data type built into javascript language.
  • Math object in JavaScriptPhoto of Math object in JavaScript
    the math object gives you properties and methods for constants and mathematical functions. unlike other global objects, math is not a constructor. all properties and methods of math are static (static) and can be called using math as an object without having to create it.
  • Regular Expression and RegExp in JavaScriptPhoto of Regular Expression and RegExp in JavaScript
    a regular expression is an object that describes a pattern of characters.
  • Document Object Model (DOM) in JavaScriptPhoto of Document Object Model (DOM) in JavaScript
    each site resides within a browser window that can be viewed as an object.