Back to Main Documentation Page
The JS Strict Data Types Boolean method allows you to define a variable as a Boolean data type and maintain the value as a Boolean. The Boolean method returns true or false, but will accept true, false, 1 or 0.
To identify a variable as a Boolean you would write the below code (where OptionalBooleanValue is some Boolean value, if no value is inserted then an empty Boolean is returned).
MyVar1 = new Boolean(OptionalBooleanValue);
To return the data type of the Boolean you would use the DataType property.
alert(MyVar1.DataType);
To set the value of the Boolean to a new value you would use the below code (where BooleanValue is some Boolean value).
MyVar1.Set(BooleanValue);
To get the value of a Boolean you would use the value property (the below would display the value).
alert(MyVar1.value);
To compare if a Boolean is equal to the Boolean value you would use the CompareEq method as seen below (below is how you would use the CompareEq method in an if statement, where BooleanValue is some Boolean value).
if(MyVar1.CompareEq(BooleanValue)){
alert("Statement is Equal");
{
To compare if a Boolean is not equal to the Boolean value you would use the CompareNotEq method as seen below (below is how you would use the CompareNotEq method in an if statement, where BooleanValue is some Boolean value).
if(MyVar1.CompareNotEq(BooleanValue)){
alert("Statement is not Equal");
{
Below is an example of how you would use a function to maintain a Boolean value.
function TestFunction(MyVar1){
//Set the Data Type of each Variable
MyVar1 = new Boolean(MyVar1);
alert("MyVar1 = " + MyVar.value);
}
Delicious
Digg
StumbleUpon
Propeller
Reddit
Magnoliacom
Newsvine
Furl
Facebook
Google
Yahoo
Technorati
Icerocket
Recent comments
12 hours 8 min ago
1 day 12 hours ago
2 days 5 hours ago
2 days 8 hours ago
2 days 20 hours ago
2 days 22 hours ago
6 days 12 hours ago
1 week 2 days ago
1 week 2 days ago
2 weeks 9 hours ago