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

JavaScript Boolean (Boolean) object related knowledge and usage

jacklove
Release: 2018-05-07 10:21:36
Original
2177 people have browsed it

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();
Copy after login

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

0
-0
null
""
false
undefined
NaN
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template