Open In App
Related Articles

JavaScript SyntaxError – “0”-prefixed octal literals and octal escape sequences are deprecated

Improve Article
Improve
Save Article
Save
Like Article
Like

This JavaScript exception 0-prefixed octal literals and octal escape sequences are deprecated works in strict mode only. For octal literals, the “0o” prefix can be used instead.

Message:

SyntaxError: Octal numeric literals and escape characters
             not allowed in strict mode (Edge)
SyntaxError: "0"-prefixed octal literals and octal escape 
              sequences are deprecated; for octal literals 
              use the "0o" prefix instead

Error Type:

SyntaxError(in strict mode only)

Cause of Error: Octal literals and octal escape sequences are deprecated and a SyntaxError will be thrown by them in strict mode. The syntax is either 0o or 0O.

Example 1: This example uses the “0”-prefixed octal literals and octal escape sequences, So the error has occurred.

Javascript




'use strict';
let a = 04; // error here


Output:

SyntaxError: Octal numeric literals and escape characters not allowed in strict mode

Example 2: In this example, “0”-prefixed octal literals and octal escape sequences are used, So the error has occurred.

Javascript




"use strict";
let a = "\251"; // error here


Output:

SyntaxError: Octal numeric literals and escape characters not allowed in strict mode
Whether you're preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape, GeeksforGeeks 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!

Last Updated : 05 Jun, 2023
Like Article
Save Article
Similar Reads
Related Tutorials