Availability
JavaScript 1.1; JScript 2.0; ECMAScript
v1
Inherits from/Overrides
Inherits from Object
Constructor
new Boolean(value) //Constructor functionBoolean(value) // Conversion function
Arguments
value
The value to be held by the Boolean object or to be converted to a
boolean value.
Returns
When invoked as a constructor with the new
operator, Boolean( ) converts its argument to a
boolean value and returns a Boolean object that contains that value.
When invoked as a function, without the new
operator, Boolean( ) simply converts its argument
to a primitive boolean value and returns that value.
The values 0, NaN, null, the empty string
", and the undefined value are
all converted to false. All other primitive
values, except false (but including the string
"false"), and all objects and arrays are converted to
true.
Methods
toString( )
Returns true or false,
depending on the boolean value represented by the Boolean object.
valueOf( )
Returns the primitive boolean value contained in the Boolean object.
Description
Boolean values are a fundamental data
type in JavaScript. The Boolean object is an object wrapper around
the boolean value. This Boolean object type exists primarily to
provide a toString( ) method to convert boolean
values to strings. When the toString( ) method is
invoked to convert a boolean value to a
string (and it is often invoked
implicitly by JavaScript) JavaScript internally converts the boolean
value to a transient Boolean object, on which the method can be
invoked.
See Also
Object
•
Table of Contents
•
Index
•
Reviews
•
Examples
•
Reader Reviews
•
Errata
JavaScript: The Definitive Guide, 4th Edition
By
David Flanagan
Publisher
: O'Reilly
Pub Date
: November 2001
ISBN
: 0-596-00048-0
Pages
: 936
Slots
: 1
This fourth edition of the definitive reference to
JavaScript, a scripting language that can be embedded
directly in web pages, covers the latest version of the
language, JavaScript 1.5, as supported by Netscape 6 and
Internet Explorer 6. The book also provides complete
coverage of the W3C DOM standard (Level 1 and Level 2),
while retaining material on the legacy Level 0 DOM for
backward compatibility.