Join Digital Nomads and Remote Workers to Ask Questions, Share Experiences, Find Remote Jobs and Seek Recommendations.

JavaScript Comparison and Logical Operators

,

JavaScript comparison and logical operator testing the conditional statement that either return true or false.

Comparison Operators

OperatorDescription
==Equal To
===Equal Both Value and Type
!=Not Equal To
!==Not Equal To Either Type or Value
>Greater Than
<Less Than
>=Greater Than or Equal To
<=Less Than or Equal To

Equal (==)

It doesn’t matter the value type, if both value are same, it will return true. Otherwise, it will return false.

5 == 5 // true
5 == "5" // true
5 == "a" // false
5 == 10 // false

Strict Equal ===

Strict equal will return true is both type and value are same. If the type or value not the same, it will return false.

5 === 5 // true
5 === "5" // false
5 === "a" // false
5 === 10 // false

Not Equal !=

If the

5 != 5 // false
5 != "5" // false
5 != "a" // true
5 != 10 // true

Strict Not Equal !==

5 !== 5 // false
5 !== "5" // true
5 !== "a" // true
5 !== 10 // true

Greater Than >

If the value is greater than the left operand, it will return true. Otherwise, it will return false.

5 > 3 // true
5 > 5 // false
5 > 10 // false

Less Than <

If the value is less than the left operand, it will return true. Otherwise, it will return false.

5 < 3 // false
5 < 5 // false
5 < 10 // true

Greater Than or Equal To >=

5 >= 3 // true
5 >= 5 // false
5 >= 10 // true

Less Than or Equal To <=

5 <= 3 // true
5 <= 5 // false
5 <= 10 // true

Logical Operators

OperatorDescription
&&Logical AND: true if both operand are true, else evaluates as false
||Logical OR: true if either one operand are true. false if both operand are false
!Logical NOT: true if the operand is !false and vice-versa.

Logical AND Operator

true if both operand are true, else evaluates as false

true && true; // true
true && false; // false
false && true; // false
false && false; //false

Logical OR Operator

true if either one operand are true. false if both operand are false

true || true; // true
true || false; // true
false || true; // true
false || false; //false

Logical NOT Operator

true if the operand is !false and vice-versa.

!true; // false
!false; // true

We Work From Anywhere

Find Remote Jobs, Ask Questions, Connect With Digital Nomads, and Live Your Best Location-Independent Life.