The strict equality operator identifies 0
and -0
as being equal.
console.log(0 === -0) // true
... so is Math.sign
the only way to distinguish these values?
The strict equality operator identifies 0
and -0
as being equal.
console.log(0 === -0) // true
... so is Math.sign
the only way to distinguish these values?
You can also use Object.is
:
const num1 = 0;
const num2 = -0;
console.log(Object.is(num1, num2));
console.log(Object.is(num1, num1));