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.
5 ★ | 1 Vote
You should read it
- ! = and! == What is the difference in JavaScript?
- Operator in JavaScript
- Operator in PHP
- Boolean operators AND and OR in SQL
- Operator in C ++
- C Shell operators
- Void keywords in JavaScript
- Basic Shell operators
- Korn Shell Operator
- Comparison operators in SQL Server
- Load the stack of assignment operators in C ++
- Overload binary operators in C ++
Maybe you are interested
The surprising truth is that many Gen Zers don't know how to type with 10 fingers.
If you're not already using this type of keyboard, it's time to switch!
This WhatsApp feature saves you from having to retype messages
Don't build a smart house without these 4 types of devices!
This is the type of password that takes 34,000 years to crack
What type of smartphone camera grid is best?