The Math.sign() polyfill contains two type conversions

UNCONFIRMED
Unassigned

Status

defect
P5
normal
UNCONFIRMED
3 years ago
3 years ago

People

(Reporter: lucas, Unassigned)

Tracking

Details

()

:: Developer Documentation Request

      Request Type: Correction
     Gecko Version: unspecified
 Technical Contact: 

:: Details

Is that not redundant? Why not `x = Number(x);` on line 2 then `return x;` on line 4? I'm guessing there's some quirk I'm not aware of.
Component: General → JavaScript
The Polyfill now contains comments that mention the edge cases a spec-conforming Polyfill needs to take care of.

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/sign#Polyfill
Status: UNCONFIRMED → RESOLVED
Closed: 3 years ago
Resolution: --- → FIXED
That's good information but not the problem I reported. I'll reduce it to this:

For what x does "Number(x) !== +x" hold true?

If none, then why not "return x;" instead of "return Number(x);"?
Status: RESOLVED → UNCONFIRMED
Resolution: FIXED → ---
You need to log in before you can comment on or make changes to this bug.