Tuesday, January 3, 2017

Booleans Reflection Journal



          From the w3schools articles on booleans, I learned that booleans have only true or false values.   Comparison and Logical operator are used to test for true or false. Some examples of the operators are == (equal to), < (less than), and > (greater than). When using the == operator, equal Booleans are equal. The boolean value of 0 is false. The boolean value of -0 is false. The boolean value of an empty string is false. The Boolean value of undefined, null, false and NaN is false. Booleans can be defined as objects by using var x = new Boolean(false);. In the === operator, equal booleans aren't equal because it expects equality on both sides. Objects CAN'T be compared. The conditional (ternary) operator assigns a value to a variable based on some condition. 
The syntax is:
variablename = (condition) ? value1:value2.
When comparing a string with a number, the string is converted into a number during the comparison. An empty string is converted to the number 0. 

No comments:

Post a Comment