JavaScript Object -- Boolean

Source: Internet
Author: User
The Boolean object represents two values: & quot; true & quot; or & quot; false & quot ;. Syntax for creating a Boolean object: newBoolean (value); // constructor Boolean (value ); // The value of the conversion function parameter is stored by a Boolean object or is to be converted to a Boolean value...

Boolean object

Boolean indicates two values: "true" or "false ".

Syntax for creating a Boolean object:

New Boolean (value); // Constructor

Boolean (value); // Conversion Function

Parameters

The parameter value is the value stored by a Boolean object or converted to a Boolean value.

Return Value

When called as a constructor (with the new operator), Boolean () converts its parameters into a Boolean value and returns a Boolean object containing the value.

When called as a function (without the new operator), Boolean () only converts its parameters into an original Boolean value and returns this value.

Note: If the value parameter is omitted or set to 0,-0, null, "", false, undefined, Or NaN, the object is set to false. Otherwise, set it to true (even if the value parameter is a string "false ").

Boolean Object Attributes

FF: Firefox, IE: Internet Explorer

Attribute
Description
FF
IE
 
Constructor
Returns a reference to the Boolean function that creates this object.
1
4
 
Prototype
Allows you to add attributes and methods to objects.
1
4
 

Boolean object Method

FF: Firefox, IE: Internet Explorer

Method
Description
FF
IE
 
ToSource ()
Returns the source code of the object.
1
-
 
ToString ()
Converts a logical value to a string and returns the result.
1
4
 
ValueOf ()
Returns the original value of a Boolean object.
1
4
 

Boolean Object Description

In JavaScript, a Boolean value is a basic data type. A Boolean object is a Boolean object that packs a Boolean value. A Boolean object is mainly used to convert a Boolean value to a string's toString () method.

When the toString () method is called to convert a Boolean value to a string (usually called implicitly by JavaScript), JavaScript internally converts the Boolean value to a temporary Boolean object, then, call the toString () method of this object.

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.