Are +0 and -0 the same?

后端 未结 9 2051
花落未央
花落未央 2020-11-22 07:45

Reading through the ECMAScript 5.1 specification, +0 and -0 are distinguished.

Why then does +0 === -0 evaluate to true<

9条回答
  •  野趣味
    野趣味 (楼主)
    2020-11-22 08:04

    We can use Object.is to distinguish +0 and -0, and one more thing, NaN==NaN.

    Object.is(+0,-0) //false
    
    Object.is(NaN,NaN) //true
    

提交回复
热议问题