Interview Questions JavaScript

Interview Question: Difference between “ == “ and “ === “ operators.

Both are comparison operators. The difference between both the operators is that,“==” is used to compare values whereas, “ === “ is used to compare both value and types.

var a = 2;
var b = “2”;
(a == b) // Returns true since the value of both a and b is the same
(a === b) // Returns false since the typeof a is “number” and typeof b is “string”