mirror of
https://github.com/kamranahmedse/developer-roadmap.git
synced 2025-08-30 20:49:49 +02:00
Add comparison operators docs (#1814)
* Update 101-value-comparison-operators.md * Update content/roadmaps/106-javascript/content/105-javascript-equality-comparisons/101-value-comparison-operators.md Co-authored-by: Kamran Ahmed <kamranahmed.se@gmail.com>
This commit is contained in:
committed by
GitHub
parent
4d586a4705
commit
e3a45167f5
@@ -1 +1,11 @@
|
||||
# Value comparison operators
|
||||
# Value Comparison Operators
|
||||
|
||||
In javascript, the `==` operator does the type conversion of the operands before comparison, whereas the === operator compares the values and the data types of the operands. The `Object.is()` method determines whether two values are the same value: `Object.is(value1, value2)`.
|
||||
|
||||
`Object.is()` is not equivalent to the `==` operator. The `==` operator applies various coercions to both sides (if they are not the same type) before testing for equality (resulting in such behavior as `"" == false` being `true`), but `Object.is()` doesn't coerce either value.
|
||||
|
||||
`Object.is()` is also not equivalent to the `===` operator. The only difference between `Object.is()` and `===` is in their treatment of signed zeros and `NaN` values. The `===` operator (and the `==` operator) treats the number values `-0` and `+0` as equal but treats `NaN` as not equal to each other.
|
||||
|
||||
<ResourceGroupTitle>Free Content</ResourceGroupTitle>
|
||||
<BadgeLink colorScheme='yellow' badgeText='Read' href='https://www.scaler.com/topics/javascript/difference-between-double-equals-and-triple-equals-in-javascript/'>The Difference Between == and === in Javascript</BadgeLink>
|
||||
<BadgeLink colorScheme='yellow' badgeText='Read' href='https://developer.mozilla.org/en-US/docs/Web/JavaScript/Equality_comparisons_and_sameness#same-value_equality_using_object.is'>Equality comparisons and sameness - MDN</BadgeLink>
|
||||
|
Reference in New Issue
Block a user