denysdovhan / wtfjs

🤪 A list of funny and tricky JavaScript examples
http://bit.ly/wtfjavascript
Do What The F*ck You Want To Public License
34.99k stars 2.55k forks source link

parseInt octals issue was fixed by ES5 #10

Closed qgustavor closed 7 years ago

qgustavor commented 7 years ago

As in MDN "ECMAScript 5 removes octal interpretation". ES5 compatibility table shows only Konq 4.14 and obsolete platforms (Opera 12 and older, IE 8 and older, and Rhino) still have this issue.

Not related to octals, but something to add on:

// parseInt always convert input to string:
parseInt({toString: () => 2, valueOf: () => 1}) // -> 2
Number({toString: () => 2, valueOf: () => 1}) // -> 1
denysdovhan commented 7 years ago

Hi, @qgustavor ! Thanks for reaching out!

Could you make a PR?