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
DeceptionAds Warning: New Malicious Ad Type Exploits Legitimate Services to Display Fake CAPTCHAs
How to type Pinyin on Windows 11 computer
Is it easier to type math equations on Google Docs or Word?
7 Types of Devices That Need a Factory Reset Before Selling
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!