SyntaxErr: Not legal ECMA-262 octal constant JavaScript – Code Example

Total
0
Shares

In this article we will learn with code example, how to resolve SyntaxError: number is not a legal ECMA-262 octal constant. Octal numbers are in the range 0-7. Any number out of this range like 8 or 9 won’t be an octal digit. Using this will throw Syntax Error.

Also, this way of using octal numbers are deprecated. Use new syntax – 0o or 0O followed by octal number.

Code Example –

SyntaxError code –

08
09

Correct code –

0o10
0O11