Wednesday, July 3, 2024
HomeLanguagesJavascriptJavaScript SyntaxError – “x” is not a legal ECMA-262 octal constant

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

This JavaScript warning 08 (or 09) is not a legal ECMA-262 octal constant that 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:

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 to 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 an octal number.

Javascript




"use strict";
// Error here
08;


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 an octal number.

Javascript




"use strict";
// Error here
09;


Output:

Warning: SyntaxError: 09 is not a legal ECMA-262 octal constant.
Whether you’re preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape, neveropen Courses are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we’ve already empowered, and we’re here to do the same for you. Don’t miss out – check it out now!

Thapelo Manthata
I’m a desktop support specialist transitioning into a SharePoint developer role by day and Software Engineering student by night. My superpowers include customer service, coding, the Microsoft office 365 suite including SharePoint and power platform.
RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular

Recent Comments