How can we help?

What's the difference between "==" and "===" operator?

Updated

When programming in JavaScript, you'll need to compare variables sometimes. To do so, you can use the operators "==" and "===," they will tell you if the outcome of the comparison is true or false. Even though these operators look very similar, they differ when comparing the variables' elements:

  • ==: compares the value of the variables
  • ===: compares the type and value of the variables

For example, 5 === "5" will return a false result. Even though the value of both variables is the same, their type is not; one of them is a String ("5"), and the other one is an Integer (5).

On the other hand,  5 == "5" will return a true result. Both variables have the same value; therefore, the result will be true.