JavaScript Tutorial

Javascript Booleans

In JavaScript, a boolean is a data type that represents either true or false. Boolean values are commonly used in conditional statements and logical operations.

Booleans can be objects

We can create the JavaScript Boolean object by Boolean() constructor as given below:-

Boolean b=new Boolean(value);

Note:- The Boolean value of an expression is the basis for all JavaScript comparisons and conditions.

Input:-

Output:-

Comparison and Conditions

We can evaluate any value using comparison operators. Below are some examples: 

Operator

Description

Example

>

greater than

if (salary > 4000)

<

less than

if (age < 30)

==

equal to

if (day == "Sunday")

Boolean Examples

Here are some examples which illustrate the usage of Boolean.

Input:-

Output:-

 

 

Go back to Previous Course