Boolean.parse Function
Converts a string representation of a logical value to its Boolean Object object equivalent. This function is static and can be invoked without creating an instance of the object.
Syntax
var booleanVar = Boolean.parse("true");
Arguments
|
Term
|
Definition
|
|
value
|
A string representation of either true or false.
|
Return Value
A Boolean value (true or false) that corresponds to the value argument.
Exceptions
Remarks
Use the parse function to create a Boolean value from a string representation. The value argument must be "true" or "false" (case insensitive). The string can contain white space. If the string cannot be converted to a Boolean value, an exception is thrown.
Example
The following example shows how to use the parse function to create a Boolean value from a string.
JavaScript
var a = new Boolean(true);
if (a == true){
alert("a = true");
}else{
alert("a = false");
}
var b = Boolean.parse("true");
if (b == true){
alert("b = true");
}else{
alert("b = false");
}