Closed TarekAlQaddy closed 7 years ago
Nice tips! Thanks @TarekAlQaddy 👍
Thanks @loverajoel
Thank you for the contribution, however, is this a tip? For me it seems like this is more useful for edge cases.
In addition, this might have lower perf as it is a function call vs. native syntax. For newbies that are subscribed to jstips this might look like "always use Object.is
instead of ===
".
@kurtextrem Thanks for your interest, When the native syntax lacks that kind of strictness, The function call would be a good replacement and I think that's why they made Object.is in ES6. for newbies what I meant that if they only want a strict version of comparisons they should go with it yes. in java for example we sometimes use Object.equals in comparisons.
besides NaN, are there other cases Object.is
handles that ===
does not?
@r-obert as I mentioned there is also -0 === +0 which gives true but by Object.is it's false
You can check Mozilla reference http://developer.mozilla.org/en-US/docs/Web/JavaScript/Equality_comparisons_and_sameness
thanks @TarekAlQaddy
Why you should use Object.is() in Equality Comparison in JavaScript
TL;DR;
a good solution for the looseness of equality comparisons in javascript
TarekAlQaddy
@TarekAlQaddy