5.2.2. Strict Equality With === code example

Example: 5.2.2. Strict Equality With ===

/*The operator === compares two operands without converting their data
types. In other words, if a and b are of different data types (say, a is
a string and b is a number) then a === b will always be false.*/

console.log(7 === "7");
console.log(0 === false);
console.log(0 === '');

//false
//false
//false 

/*For this reason, the === operator is often said to measure strict 
equality.

Just as equality operator == has the inequality operator !=, there is 
also a strict inequality operator, !==. The boolean expression 
a !== b returns true when the two operands are of different types, 
or if they are of the same type and have different values.

Tip
USE === AND !== WHENEVER POSSIBLE. In this book we will use these 
strict operators over the loose operators from now on.*/

Tags:

Misc Example