denysdovhan / wtfjs

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

parseInt problem #30

Closed killagu closed 7 years ago

killagu commented 7 years ago

in parseInt is a bad guy section

parseInt('08'); // 0

but i have executed the code in chrome and node.js , the result is 8

DimitarNestorov commented 7 years ago

Since ES 2015 parseInt's second argument defaults to 10. In other words it will return 0 in an older browser.