Skip to content
Related Articles

Related Articles

Improve Article
Save Article
Like Article

JavaScript SyntaxError – “x” is not a legal ECMA-262 octal constant

  • Last Updated : 19 Aug, 2020

This JavaScript warning 08 (or 09) is not a legal ECMA-262 octal constant occurs if the literals 08 or 09 are used as a number. This occurs because these literals cannot be treated as an octal number.

Message:

Hey geek! The constant emerging technologies in the world of web development always keeps the excitement for this subject through the roof. But before you tackle the big projects, we suggest you start by learning the basics. Kickstart your web development journey by learning JS concepts with our JavaScript Course. Now at it's lowest price ever!

Warning: SyntaxError: 08 is not a legal ECMA-262 octal constant.
Warning: SyntaxError: 09 is not a legal ECMA-262 octal constant.

Error Type:

Warning. JavaScript execution won't be halted.

Cause of Error: This happens when any of the digits after the leading 0 is equal or greater than 8. This number cannot be treated as an octal number and therefore JavaScript gives a warning about it.



Example 1: In this example, the literal ’08’ gives a warning because it can not be interpreted as octal number.

HTML




<script>
"use strict";
// Error here
08;
</script>

Output:

Warning: SyntaxError: 08 is not a legal ECMA-262 octal constant.

Example 2: In this example, the literal ’09’ gives a warning because it can not be interpreted as octal number.

HTML




<script>
"use strict";
// Error here
09;
</script>

Output:

Warning: SyntaxError: 09 is not a legal ECMA-262 octal constant.
My Personal Notes arrow_drop_up
Recommended Articles
Page :

Start Your Coding Journey Now!