Difference between == VS ===
Equality VS Strict Equaity

Difference between == VS ===

const Num1 = 1;
const Num2 = 1;
console.log(Num1 == Num2); //output is true
console.log(Num1 === Num2); // output is true        
💡 Now you will say, What’s new in this!!!!
**const Num1 = 1;
const string = “1”; // string is here
console.log(Num1 == Num2); // True
console.log(Num1 === Num2); // False**        

Let me explain you Now!!!!!

  1. == called as Double Operator, Known as Equality or abstract Comparison
  2. === called as Triple Operator, Known as Identity or Strict Comparision
  3. Performance is totally irrelevant, == vs === is faster is totally a myth
  4. == converts the variable values to the same type before performing comparison.

const num = 1;
const num1 = “1”;
console.log(num == num1); // Returns TRUE        
💡 This returns true as it is converted the type, and so if it is false also it returns True

=== does not do any type conversion (coercion) and returns true

only if both values and types are identical for the two variables***

const num = 1;
const num1 = “1”;
console.log(num == num1); // Returns FALSE        
💡 This returns False, as the type remains Identical

Chalo shuru karo Abb!!!!!!!🙌🙌🙌🙌🙌🙌

To view or add a comment, sign in

More articles by G Shabrez

Insights from the community

Others also viewed

Explore topics