The error is due to Esprima, which r.js uses internally. To reproduce the problem, you can go to this page and enter var x = 08;
Generally speaking, it seems that JavaScript interpreters will process a number with a leading zero, which can be interpreted as an octal number as an octal number, but if it cannot be interpreted as an octal number (for example, 08), then they will consider it as a decimal.
I ran a test with Node.js and got the following:
$ node > 07 7 > 08 8 > 09 9 > 010 8 >
And even more fun:
> (function () {'use strict'; var x = 08;})() undefined > (function () {'use strict'; var x = 012;})() SyntaxError: Octal literals are not allowed in strict mode. [ ... traceback deleted ...]
When strict mode is enabled, octal values ββare illegal.
I would avoid octal and never prefix numbers with zeros in JavaScript.
Louis
source share