-0is considered equal to
Strict equality, SameValueZero, and SameValue are almost equivalent. They only differ in their handling of
-0. For all other values, the last 3 algorithms are identical.
NaN is not strictly equal to any value, not even itself. In other words,
NaN !== NaN. Also,
(+0) === (-0).
Object.is() function implements the SameValue algorithm. With the SameValue algorithm,
NaN is equal to itself:
Object.is(NaN, NaN) === true. But, on the other hand,
+0 is not equal to
Object.is(+0, -0) === false.
SameValueZero: There's no way to use SameValueZero directly, but the Array#includes()
[method](https://masteringjs.io/tutorials/fundamentals/array-includes) uses SameValueZero internally. So, to try out SameValueZero, you can useincludes(). The only difference between SameValue and SameValueZero is that SameValueZero treats
+0 as equal to
[+0].includes(-0) === true.
As a developer, you should typically use
===, with the understanding that you may need to add a special case if you care about
NaN. The distinction between
-0 is not important for most use cases.
yare the same type, check if
x === y.
yare both either
xis a number and
yis a string, convert
yto a number and then compare using
===. Similarly, if
xis a boolean or string, and
yis a number, convert
xto a number.
yis a boolean, convert the other value of a number and compare them.
xis an object and
yis a symbol, string, or number, try to convert
xto a primitive using valueOf() and then compare using
With the rapid development in technology, the old ways to do business have changed completely. A lot more advanced and developed ways are ...
You name the business and I will tell you how web development can help you promote your business. If it is a startup or you seeking some...
Top 10 Web Development Trends in 2020 will provide you with a detailed list of the trends which are currently being noticed. Upskilling to these trends will help you in landing onto better jobs in 2020-2021.