During experiments with JavaScript. I tested a few odd code snippets, here are some of my conclusions (to understand how I came across -0 ),
When doing +[] in the console, this returns 0 . I'm not sure why, but it is. So this means that the positive array has a value of 0 ..
After that, I became curious and tried the following:
console.log(-[]);
And that returns -0 ...
What is the meaning of -0? 0 and -0 are both irrelevant, so negation is really not necessary ... Or is it like that? Maybe JavaScript has a target for -0?
Adding to this. I can not find another way to play -0 , except using -0 itself, or using -[] ...
Some other strange finds, my question is about -0
(-0) + (-0) = 0 (-0) - (-0) = -0 (-0) * (-0) = 0 (-0) / (-0) = NaN
user3117575
source share