The last few days I was in where I spoke at the excellent . In the talk (the recording is from a different event though) of I saw a very interesting code snippet. Cluj-Napoca JSHeroes conference “V8 Internals for JS Developers” Mathias Bynens Object.is(-0, +0); This single line is fascinating in two ways — let’s have a look at it. The two existent zeros in JavaScript The first fact is that numbers in are following . This standard is available in several variants, and JavaScript uses “Double precision” also called “binary64” based on 64 bits. JavaScript the IEEE Standard for Floating-Point Arithmetic IEEE 754 defines that . To understand how this works it may take some time but the important fact is that there is one bit (the sign bit) in JavaScript numbers which defines if a number is positive or negative which means that can be negative, too. a sign, a significand, and an exponent to describe each finite number 0 const posNumber = 1;const negNumber = -1;const posZero = +0;const negZero = -0; My first reaction to the discovery of negative zeros was that I surely don’t have these in my code, but well… when I round I'll end up with a negative zero as well which makes it more likely that a negative zero appears in my JavaScript, too. -0.23 Math.round(-0.23); // -0 It becomes when you want to compare positive and negative zeros though because they’re treated the same. interesting -0 === +0 // true wrote and there is even on positive and negative zeros going more into more details if you’re interested. AbdulFattah Popoola a nice article a section in the “You don’t know JavaScript” series Sidenote: you can differentiate _-0_ and _0_ using division and the resulting _Infinity_ . 1 / -0 === -Infinity // true 1 / 0 === Infinity // true-Infinity !== Infinity // true Object.is — comparing without quirks? So, the strict comparison with didn't catch the fact that the two zeros are not the same. You may know that is also not equal to either. === NaN NaN NaN === NaN // false // you can use Number.isNaN as an alternativeNumber.isNaN(NaN) // true These occacsion are when comes into play. In most cases, it behaves the same as but it includes some minor "improvements" which make things a bit more logical. Object.is === Object.is(-0, 0); // false Object.is(NaN, NaN); // true The downside of this is that not everybody is aware of the existence of which means that for the rounding of a differentiation between and could lead to hard to spot bugs. That's probably why it's usually ignored in JavaScript. -0 -0.23 0 -0 I saw for the first time in Mathias' slides and it doesn't seem to be used that often. Object.is One question that came to mind immediately was if it is as fast as . I created to see how performs in comparison to . In Safari and Firefox seems to be significantly slower than whereas in Chrome it's more or less the same. That's very interesting! Object.is === a quick JSPerf Object.is === Object.is === If anyone has comments on the performance test, please let me know. Browser internals are extremely complicated and, sometimes an optimization takes place in a test which then invalidates the whole thing. I’d also love to here if you use in your source code! :) Object.is Originally published at www.stefanjudis.com .