When the Boolean() constructor is called as a function, it performs a type conversion on the value that is passed to it as a parameter.
The following results are yielded by the Boolean() constructor function:
Value: | Result: |
---|---|
No value | false |
undefined | false |
null | false |
Boolean false | false |
Boolean true | true |
NaN | false |
0 | false |
Non zero number | true |
Zero length string "" | false |
Non zero length string | true |
Object | true |
The result will be true or false depending on the parameter's value. If the parameter value is omitted, then false is returned by default.
ECMA 262 edition 2 - section - 15.1.3.5
ECMA 262 edition 2 - section - 15.6.1
ECMA 262 edition 2 - section - 15.6.2
ECMA 262 edition 2 - section - 15.6.3
ECMA 262 edition 3 - section - 15.6.1
Prev | Home | Next |
Boolean() | Up | Boolean.Class |
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. |