Wednesday, September 25, 2024
Google search engine
HomeLanguagesJavascriptJavaScript SyntaxError – Applying the ‘delete’ operator to an unqualified name is...

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

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 neveropen";
console.log(GFG);
GFG = null;


Output:

This is neveropen

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.
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!

RELATED ARTICLES

Most Popular

Recent Comments