-2

Everyone who come across comparison of objects in JavaScript struggle a lot with this topic because this syntax(===) is not represented in any other popular languages. They only have == and that’s it.

The problem is that I can’t really understand the difference between === and == and the purpose of it. We don’t have anything like that in any other popular languages like python, Java or C++.

I would like to clearly understand the pros and cons of using === in my code if you have any useful articles or other pieces of information please share.

  • Strict Equality "===" : https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Strict_equality Equality "==" : https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Equality This should help – Keval Dec 16 '21 at 12:11

1 Answers1

1

Basically, the only real difference is that === includes the type in the comparison; whereas == is just the value.

"6" == 6

Would be true, while:

"6" === 6

Would be false

Andrew Corrigan
  • 1,017
  • 6
  • 23