The values of two underlying Boolean types in javascript:
1.true
2.false
The Boolean value true represents True and false for false. The generic relational operator returns the result of a Boolean value. In addition, values of 0,-0, NULL, NaN, undefined, and null characters ("") of special values are interpreted as false, and other values are interpreted as true.
function Ismonth (Mon) {
if (Mon >= 1) && (Mon <=)) {return
true;
} else {return
false;
}
}
if (Ismonth (Mon)) {
alert ("OK");
} else {
alert ("Please enter the correct month.") ");
}
Boolean = new Boolean (value)
generates a Boolean object. Set value to the initial value true or FALSE. In order to conform to the idea that "data types can generate objects" in object-oriented form, JavaScript prepares this class, but it is basically useless.
xx = new Boolean (true);
All types in ECMAScript have values that are equivalent to TRUE or false, and to convert a value to its corresponding Boolean
Value, you can call the Transformation function Boolean ();
Boolean (NaN);//false
boolean (0);//false
Boolean (");//false
Boolean (null);//false
Boolean ( Undefined)//false
PS: You can use!! Operator converts a truthy or Falsy value to a Boolean value.
!! ""//False
!! 0//False
!! Null//False
!! Undefined//False
!! NaN//False
!! " Hello "//True
!! 1//True
!! {}//True
!! []//True