Availability: |
| ||||||||
JavaScript syntax: | - | myBoolean = BooleanValue | |||||||
- | myBoolean = new Boolean() | ||||||||
- | myBoolean = new Boolean(aValue) | ||||||||
Argument List | BooleanValue | A Boolean value (either true or false) | |||||||
aValue | A value to be converted to a Boolean object. | ||||||||
Object properties: | constructor, prototype | ||||||||
Object methods: | toSource(), toString(), valueOf() |
An instance of the class "Boolean" is created by using the new operator on the Boolean() constructor. The new object adopts the behavior of the built-in Boolean prototype object through the prototype-inheritance mechanisms.
All properties and methods of the prototype are available as if they were part of the new instance.
A Boolean object is a member of the type object and is an instance of the built-in Boolean object.
Cloning the built-in Boolean object creates Boolean objects is done by calling the Boolean() constructor with the new operator. For example:
myBoolean = new Boolean(true);
A Boolean object can be coerced into a Boolean value and can be used anywhere that a Boolean value would be expected.
Programmers familiar with object-oriented techniques may be happy to use the Boolean object, while procedural language programmers may prefer to implement the same functionality with a Boolean value instead.
This is an example of the flexibility of JavaScript in its ability to accommodate a variety of users from different backgrounds.
The prototype for the Boolean prototype object is the Object prototype object.
See also: | Boolean.prototype, Native object, Object object, unwatch(), watch() |
Property | JavaScript | JScript | N | IE | Opera | NES | ECMA | DOM | CSS | HTML | Notes |
---|---|---|---|---|---|---|---|---|---|---|---|
constructor | 1.1 ![]() | 3.0 ![]() | 3.0 ![]() | 4.0 ![]() | ![]() | ![]() | 2 ![]() | ![]() | ![]() | ![]() | - |
prototype | 1.1 ![]() | 3.0 ![]() | 3.0 ![]() | 4.0 ![]() | 3.0 ![]() | 2.0 ![]() | 2 ![]() | ![]() | ![]() | ![]() | - |
Method | JavaScript | JScript | N | IE | Opera | NES | ECMA | DOM | CSS | HTML | Notes |
---|---|---|---|---|---|---|---|---|---|---|---|
toSource() | 1.3 ![]() | ![]() | 4.06 ![]() | ![]() | 3.0 ![]() | ![]() | ![]() | ![]() | ![]() | ![]() | - |
toString() | 1.1 ![]() | 3.0 ![]() | 3.0 ![]() | 4.0 ![]() | 3.0 ![]() | 2.0 ![]() | 2 ![]() | ![]() | ![]() | ![]() | - |
valueOf() | 1.1 ![]() | 3.0 ![]() | 3.0 ![]() | 4.0 ![]() | ![]() | ![]() | 2 ![]() | ![]() | ![]() | ![]() | - |
ECMA 262 edition 2 - section - 4.3.15
ECMA 262 edition 2 - section - 10.1.5
ECMA 262 edition 2 - section - 15.6
ECMA 262 edition 3 - section - 4.3.15
ECMA 262 edition 3 - section - 15.6
Prev | Home | Next |
Boolean literal | Up | Boolean() |
JavaScript Programmer's Reference, Cliff Wootton Wrox Press (www.wrox.com) Join the Wrox JavaScript forum at p2p.wrox.com Please report problems to support@wrox.com © 2001 Wrox Press. All Rights Reserved. Terms and conditions. |