by jerhewet · 13y ago · 0 comments
EDIT -- from http://wtfjs.com:
parseInt('06'); // 6
parseInt('08'); // 0
Your language is bad, and you should feel bad.
strtol("06", NULL, 8); //6
strtol("08", NULL, 8); //0
Is C bad? Should Kernighan and Ritchie feel bad?Javascript was bad for making that design decision in 1995, when nobody seriously used octal for anything, so the leading zero was vastly more likely to introduce a class of WTF bugs instead.
Sure you can. Read the Fine manual: https://developer.mozilla.org/en-US/docs/JavaScript/Referenc...
tldr: parseInt("08", 10);
$ perl -le 'print 07'
7
$ perl -le 'print 08'
Illegal octal digit '8' at -e line 1, at end of line
Execution of -e aborted due to compilation errors.
$ python -c 'print 07'
7
$ python -c 'print 08'
File "", line 1
print 08
^
SyntaxError: invalid tokenhttps://lists.webkit.org/pipermail/webkit-dev/2011-December/...
parseInt('08', 10); // 8