Boolean
?Boolean is a type of data that can have two different values: true or false.
Do you like cat? YES
Do you like beer? NO
AND
, OR
, and NOT
JavaScript, and many other languages, support boolean data types that could be true or false. In addition to that, everything in JavaScript has an implicit boolean value that can be truthy or falsy. When you say that a value is truthy in JavaScript, it doesn’t mean that the value is true. Instead, it means that the value will result as true when evaluated in a boolean context.
Correspondingly, when you say a value is falsy in JavaScript, it means the value translates to false when evaluated in a Boolean context.
3 different data types in JS
undefined
is a value, automatically set by JS, to a variable that was declared, but not initialized with a value.null
is a type of data in JS that points, generally intentional, to a non-existing value.NaN
or Not a Number is commonly the result of trying to apply Number methods to data types that are not numbers.