14

What is the difference between "==" and "===" in JavaScript?

Comments
  • 7
    I usually ask this at interviews. So many 'senior' developers that don't know the difference
  • 12
    Answer: there is one more =
  • 0
    I got this one recently.
  • 1
    == will return true if you are comparing 1 to "1", === will not
  • 4
    One is scary, the other is sane.
  • 2
    @kaqqao I guess the big issue is that we live in a world where this is a reasonable question, which would imply that people fire away their applications like tommy guns without actually knowing shit.
  • 4
    == equals
    === very equals
  • 1
    @DLMousey and so `===` is faster and cleaner because it won't cast any of the operands before comparing.

    ..just wanted to add that.😪
  • 3
    This is part of the very foundation your javascript program. If you cannot answer this correctly, it has a high chance of being littered with bugs. So no, this is a damn good question.

    I also was asked once what Ecmscript was. Upon answering, he was really impressed as most developers don't give a rats ass about the history of a language.
  • 0
    @MaxDeepfield the exact way I like to describe it! Well done sir.
Add Comment