How to use Javascript boolean type

Description

The Boolean type has two literal values: true and false. These values are not numeric values.

These values are distinct from numeric values, so true is not equal to 1, and false is not equal to 0.

true and false are case-sensitive, so True and False are valid as identifiers but not as Boolean values.

Example

The following code creates two boolean type variables:


var isOK = true;
console.log(isOK); 
var isNotOK = false;
console.log(isNotOK); 

The code above generates the following result.





















Home »
  Javascript »
    Javascript Introduction »




Script Element
Syntax
Data Type
Operator
Statement
Array
Primitive Wrapper Types
Function
Object-Oriented
Date
DOM
JSON
Regular Expressions