You are here: Home / Topics / Difference between “ == “ and “ === “ operators

Difference between “ == “ and “ === “ operators

Filed under: JavaScript Interview Questions on 2022-07-03 08:01:43

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

var x = 2; var y = "2"; (x == y)  // Returns true since the value of both x and y is the same

(x === y) // Returns false since the typeof x is "number" and typeof y is “string”


About Author:
M
Monu Rathod     View Profile
Giving someone what you have is great deed.