0 is a bit different from
-0 in JS.
If you divide a zero by any negative number, you’ll get
Let’s take a look at how
-0 look like when logged to the console and how these values compare to each other.
const zero = 0; const minusZero = zero / -1; console.log(zero); // 0 console.log(minusZero); // -0 console.log(zero === minusZero); // true
As you see, even though
-0 appear differently when logged to the console, they appear
equal when compared using the strict equality operator.
If you need a function that would tell the explicit difference between
you can use
Object.is(-0, +0); // false