The difference between the == and === operators in JavaScript
The == operator compares the abstract equality, that is, it performs the necessary type conversions before comparing the equality. The === operator compares strict equality, meaning that it will not perform type conversions.
In JavaScript, the == and === operators are used to compare between two operands.
The == operator abstracts, that is, it makes the necessary type conversions before comparing the equality. Syntax of comparison: a == b .
The === operator compares strict equality, meaning that it will not perform type conversions. So if two values are not of the same type, then when compared, the result will return false. Syntax of comparison: a === b .
Example 1:
Output:
true false Example 2:
Output:
true false Example 3:
Output:
true false In general, the === operator is recommended because it never performs type conversions when making comparisons, so it always produces accurate results.
Readers can learn more about other operators in the article: Operators in JavaScript.
Discover more
JavaScript operators operators in JavaScriptShare by
David Pac
Update 11 February 2020
You should read it
- Operator in PHP
- Boolean operators AND and OR in SQL
- Operator in C ++
- C Shell operators
- Void keywords in JavaScript
- The Quiet Details That Make a Sports Betting Platform Feel Reliable
- Instructions on creating toy set images with ChatGPT AI
- How are AI agents changing the journalism industry?
- How to stop receiving Messenger chat groups without deleting the group
- Gamers received 9000 criminal charges, 5 years in prison, fined 800 million for profiteering from the game
- Difference between LAN, MAN and WAN