Skip to content
Related Articles

Related Articles

Improve Article
JavaScript SyntaxError – “0”-prefixed octal literals and octal escape sequences are deprecated
  • Last Updated : 31 Jul, 2020

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.



HTML




<script
   'use strict';
    var a = 04; // error here
</script>

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.

HTML




<script
   "use strict";
   var a = "\251"; // error here
</script>

Output:

SyntaxError: Octal numeric literals and escape characters not allowed in strict mode
My Personal Notes arrow_drop_up
Recommended Articles
Page :