I was reading the ECMAScript 5.1 spec. It says:
The
slicemethod takes two arguments, start and end [...]. If start is negative, it is treated as length+start where length is the length of the array. If end is negative, it is treated as length+end where length is the length of the array.
What does "negative" mean? It makes sense that, like in math,
- If
num > 0, thennumit is positive - If
num < 0, thennumis negative.
But what about +0 and -0? In math there is a single 0, which is not positive nor negative. My guess was that, in ECMAScript,
+0(a.k.a. positive zero) is positive.-0(a.k.a. negative zero) is negative.
But I tried using -0 with slice, and browsers treat it as non-negative.
Then, are both +0 and -0 non-positive and non-negative, despite their names?
Where is the positiveness or negativeness of a number defined? I didn't find that defined in the ECMAScript spec. Is the definition inherited from IEEE 754?