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.
'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.
"use strict" ;
let a = "\251" ; // error here
|
Output:
SyntaxError: Octal numeric literals and escape characters not allowed in strict mode