+ 2
What is the "Boolean" in the js? I didn't under stand it. Please help me..
3 Réponses
+ 10
Variables are containers for storing data values, remember? Well, these data values can have different types, one of them is the "boolean" type. Examples:
1) The following is a variable called "Age" with a data type of "number" because its number value is 16:
var Age = 16;
2) The following is a variable called "Name" with a data type of "string" because its text value is "Vigneshwar":
var Name = "Vigneshwar";
3) The following is a variable called "Male" with a data type of "boolean" because its value is true:
var Male = true;
Just remember that Booleans can only have 2 values: true or false. And they are often used in conditional testing.
For more information about booleans: https://www.w3schools.com/js/js_booleans.asp
+ 9
Boolean variables can only hold the values "true" or the value "false". Some other values can be assigned that map to one of the two. Ex: Any number that isn't 0 is treated as assigning true.
They're usually used to check if something has(n't) occurred/succeeded or does(n't) exist, and are called flags.
+ 2
Boolean is a data type. It is used to simple check if something true or false.