== vs === in javascript

== vs === in JavaScript #6

== and === are quite different but do you know how they are different from each other?

  • == (Double equals operator): Known as the equality or abstract comparison operator
  • === (Triple equals operator): Known as the identity or strict comparison operator

The major different between these two is,

  • == converts the variable values to the same type before performing the comparison. This is called type coercion.
  • === does not do any type conversion (coercion) and returns true only if both values and types are identical for the two variables being compared.
let a = 15;               //Integer Data Type
let b = "15";             //String Data Type
console.log(a == b);      //True
console.log(a === b);     //False


== vs === in JavaScript - papaprogrammer

Previous Post: If-else in JavaScript

Leave a Reply

Your email address will not be published. Required fields are marked *

You May Also Like