Open
Description
There are several rules for variables transformation into a number. For now, only few of them are supported.
7.1.4 ToNumber ( argument )
1. If argument is a Number, return argument.
**2. If argument is either a Symbol or a BigInt, throw a TypeError exception.**
3. If argument is undefined, return NaN.
4. If argument is either null or false, return +0𝔽.
5. If argument is true, return 1𝔽.
**6. If argument is a String, return StringToNumber(argument).**
7. Assert: argument is an Object.
**8. Let primValue be ToPrimitive(argument, "number").**
**9. Assert: primValue is not an Object.**
**10. Return ToNumber(primValue).**
Now for objects it always returns NaN
which is incorrect, for example, for [0]
or objects with toString
returning a string with a number inside.
Metadata
Metadata
Assignees
Labels
No labels