Open In App

JavaScript SyntaxError – Applying the ‘delete’ operator to an unqualified name is deprecated

Last Updated : 05 Jun, 2023
Improve
Improve
Like Article
Like
Save
Share
Report

This JavaScript exception applying the ‘delete’ operator to an unqualified name is deprecated works in strict mode and it occurs if variables are tried to be deleted with the delete operator.

Message:

SyntaxError: Calling delete on expression not allowed
             in strict mode (Edge)
SyntaxError: applying the 'delete' operator to an unqualified name
             is deprecated (Firefox)
SyntaxError: Delete of an unqualified identifier in strict mode. 
             (Chrome)

Error Type:

SyntaxError

Cause of Error: In strict mode, trying to delete a variable will throw an error and is not permitted. Normal variables in JavaScript can’t be deleted with the help of the delete operator

Example 1:

Javascript




'use strict';
let GFG = "This is GeeksforGeeks";
console.log(GFG);
GFG = null;


Output:

This is GeeksforGeeks

Example 2: In this example, the delete operator is used which causes the error.

Javascript




'use strict';
let GFG = "This is GeeksForGeeks";
console.log(GFG);
delete GFG;


Output(in console):

SyntaxError: Delete of an unqualified identifier in strict mode.

Like Article
Suggest improvement
Previous
Next
Share your thoughts in the comments

Similar Reads