Everybody who used JavaScript knows that JS is loosely typed and comparing with ‘==’ gives unexpected results.
So if we use triple equals operator ‘===’, we got a more strict result, but it is also not yet perfect:
For help us in this case we use ES6 ‘Object.is()’, it is more precision than ‘===’ and moreover it behaves well in some special cases:
Compare table:
Polyfill:
If you like this article, follow me on Twitter @MaciejDEV
Top comments (4)
I had 4gotten about this.
===
really is 'good enough' - less typing thanObject.is
- Besides those edge cases, NS 😕 if it's worth it?GTK, though. JIC.
Yes, all that tests return false when you use '==='
Thank you so much for your post!
Nice post. I believe you have misplaced === code snippet with == (The second snippet)..:)