Lets chat a little bit about Equality Operator. Boolean variables(expressions) return true or false values. When it comes to comparison operators in JavaScript there are four equality operators.
Strict Equality Operators, Strict Inequality Operators, Loose Equality Operators, and Loose Inequality Operators. We are only going to focus on Strict Equality/Inequality Operators .
Lets talk about Strict Equality Operators ( ===). These operators return a value of true without a type conversion taking place. The data has to match on both sides of the expression in order for it to return true.
39 === 39;
console.log(39 === 39);
you will get the value "true"
39 === `39`;
console.log(39 === `39`)
you will get the value "false"
Desiah ==== Desiah
console.log(Desiah === Desiah)
you will get the value "true"
Desiah === `Desiah`
console.log(Desiah === `Desiah`)
you will get the value "false"
A Boolean expression returns false when comparing two values that are not the same you. Lets move on to Strict Inequality Operators.
Strict Inequality Operators return value of true when two data types are different. Lets look at some examples.
777 !== 777
console.log(777 !== 777)
you will get value "false". That is because both values are the same.
555 !== 888
console.log(777 !== 888)
you will get value "true". That is because both values are different.
Lets focus on all four relational operators:
greater than ( > ),
greater than or equals ( >= )
less than ( < )
less than or equal ( <= )
999 > 44;
console.log(999 > 23)
// => true
"9" >= "66";
console.log("9" >= "66")
// => true. In this case it is character by character based.
// 9 is bigger than 4 so it will return true. That applies on
// when comparing strings.
9 < 444;
console.log(9 < 444);
// => true 9 is bigger than 444
When comparing number against non- numbers, a type conversion will take place. A Type Conversion is when two data types that are different are converted so they are the same.
333 >= "Divine"
console.log(333 >= `Divine`)
// it will return false because a type conversion can not be made.
// This is because both values are not numbers.