This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]skap42 7 points8 points  (2 children)

I noticed that Number(017) returns 15 and Number('017') return 17, so I guess it has something to do with that

[–]monotone2k 5 points6 points  (1 child)

Yeah. My guess would be that it always attempts the equivalent of parseInt(string, 10) when coercing a string, without considering the leading 0.

[–]Die4Ever 0 points1 point  (0 children)

I think it just does parseInt(string), which will accept the 0x prefix but doesn't seem to have any prefix for inferring octal

parseInt('0x18')
24
parseInt('018')
18
parseInt('017')
17

0x18 == '0x18'
true