The decimal equivalent of octal 11, in the same way that trace(Number("0x33")) returns 51. So Karthik's statement should just be revised to say that Number is suitable and correct if the aim is to convert/cast a string representation of a decimal number into that decimal number.

Helen


Ron Wheeler wrote:

What does Number("011")  return?

Ron

Karthik wrote:

At least when working with XML, I have found Number() to be fairly inconsistent in converting strings to numbers. parseInt() seems to work everytime.


How exactly? An example would be good.

I find Number a lot more suitable and correct i.e. the aim is to
_convert_/_cast_ a string into a number. I don't want to _parse_ the
number out of a string.
e.g.
Number("1a") will return NaN.
parseInt("1a") will return 1.
Number("1 ") will return NaN.
parseInt("1 ") will return 1.

So.. Number():
a) doesn't mangle the data
b) depends on valid input - no whitespace etc.
c) is faster

-K


_______________________________________________
Flashcoders mailing list
[email protected]
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Reply via email to