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

  • Object Number in JavaScriptObject Number in JavaScript
    the number object represents the date in the form of a numeric value, or an integer or floating-point number. generally, you don't need to worry about number objects because the browser automatically converts number literals to illustrate the number classes.
  • Top site with many good JavaScript exercises to practiceTop site with many good JavaScript exercises to practice
    many people, after taking javascript courses and being equipped with some knowledge of the language they pursue, are eager to improve and cultivate these learned skills. so this article will give you a list of the top 3 websites to actually make javascript.
  • What is JavaScript?What is JavaScript?
    javascript is a programming language of html and web. it is lightweight and most commonly used as part of web pages, but their implementation allows client-side scripts to interact with users and create dynamic websites. it is an interpreted programming language with object-oriented capabilities.
  • ! = and! == What is the difference in JavaScript?! = and! == What is the difference in JavaScript?
    javascript includes operators like in other languages. an operator performs some operations on one or more operands (data values) and produces a result. today's article will help readers learn about 2! = and! == operators in javascript.
  • Learn about ES6 in JavascriptLearn about ES6 in Javascript
    es6 refers to version 6 of the ecma script programming language. ecma script is the standard name for javascript and version 6 is the next version after version 5, released in 2011.
  • Summary of JavaScript exercises with sample codeSummary of JavaScript exercises with sample code
    in order to make your javascript learning easier, tipsmake.com has compiled a number of javascript exercises with sample solutions for you to practice.
  • JavaScript location in HTML FileJavaScript location in HTML File
    there is flexibility in providing javascript code anywhere in an html document. however, the most preferred ways to include javascript in an html file.
  • How to Turn on JavaScriptHow to Turn on JavaScript
    javascript is a language used in many websites to provide additional functionality and access to the user. developers use javascript to deliver a large part of their site's functionality to you, the user. your browser must have javascript...
  • What is the difference between Java and JavaScript?What is the difference between Java and JavaScript?
    although the names of java and javascript seem to be related (javascript seems to be a script in java?), but that's the only similarity. these two languages ​​are not technically related to each other.
  • Void keywords in JavaScriptVoid keywords in JavaScript
    void is an important keyword in javascript that can be used as a unary operator before its single operand, which can be in any type. this operator defines an expression to be evaluated without returning a value.