I have a problem with following statement
trace(Number("1/2")) //output NaN
but
trace(Number("1.2")) //output 1.2
So, I am bit confused as why the first statement doesn't gives correct result?
It probably expects the value to be a number already, not a calculation. Try to parse this string: "1+2"
. It'll most likely result in NaN as well.
Edit: I've run a test
Number("1.2") = 1.2
Number("1+2") = NaN
Number("1/2") = NaN
So, as I said, the Number()
constructor expects a number, not a calculation.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With