What is Triple Equal in JavaScript?

What is Triple Equal in JavaScript?

Ferenc Almasi β€’ 2021 January 08 β€’ πŸ“– 1 min read
  • twitter
  • facebook
πŸ“’ JavaScript

Javascript uses two different equal signs for equality comparisons. You have abstract and strict equality comparison, or more commonly known as double and triple equal.

The triple equal operator is used to check for strict equality. This means that in order to define two values as equal, both the type and their value must match.

// Here we check for both value and type, therefore this will return false
'1' === 1
Copied to clipboard!

Double equal on the other hand only compares values, meaning different types can be equal if their value matches.

// Here we only check for value, therefore will return true:
'1' == 1
Copied to clipboard!

When dealing with equality checks, you should always useΒ ===Β to test for equality, otherwise your code may contain unexpected results.

What does the triple equal operator do in JavaScript?
If you would like to see more Webtips, follow @flowforfrank

50 JavaScript Interview Questions
Looking to improve your skills? Check out our interactive course to master JavaScript from start to finish.
Master JavaScript


Did you find this page helpful?
πŸ“š More Webtips
Frontend Course Dashboard
Master the Art of Frontend
  • check Unlimited access to hundreds of tutorials
  • check Access to exclusive interactive lessons
  • check Remove ads to learn without distractions
Become a Pro