Home  >  Article  >  Web Front-end  >  JavaScript Boolean (Boolean) object related knowledge and usage

JavaScript Boolean (Boolean) object related knowledge and usage

jacklove
jackloveOriginal
2018-05-07 10:21:362143browse

Boolean (Boolean) objects are used to convert non-Boolean values ​​into Boolean values ​​(true or false). This article will explain some properties.

Create a Boolean object

The Boolean object represents two values: "true" or "false"

The following code defines a Boolean object named myBoolean:

var myBoolean=new Boolean();

If the Boolean object has no initial value or its value is:

0
-0
null
""
false
undefined
NaN

Then the value of the object is false. Otherwise, its value is true (even when the variable value is the string "false")!

This article briefly explains the related properties and creation of Boolean. For more learning materials, please pay attention to the php Chinese website.

Related recommendations:

JavaScript typeof, null, and undefined related knowledge

JavaScript Date (date) related knowledge And usage

#About the usage of JavaScript Break and Continue statements

The above is the detailed content of JavaScript Boolean (Boolean) object related knowledge and usage. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn