Fixing "Delete of an unqualified identifier" Errors in JS
TheΒ "Uncaught SyntaxError: Delete of an unqualified identifier in strict mode." error occurs in JavaScript, whenever you try to use the delete
keyword on a variable in strict mode. In order to fix the error, avoid using the delete
keyword on variables.
'use strict'
const cloud = 'βοΈ'
// β This will throw "Uncaught SyntaxError: Delete of an unqualified identifier in strict mode."
delete cloud
Strict mode in JavaScript eliminates silent errors, prohibits certain syntax, and fixes mistakes that make it difficult for JS engines to perform optimizations.
In the above code example, we are using strict mode, and we try to delete a variable using the delete
keyword. In non-strict mode, this operation will only return false
. But in strict mode, we will get the following error:
Uncaught SyntaxError: Delete of an unqualified identifier in strict mode.

Why is this error happening?
The delete
operator in JavaScript cannot be used on variables. It is not allowed in strict mode, therefore you will get the above error. The delete
operator can only be used on the properties of an object. Object properties are "qualified identifiers", therefore if you use the delete
operator on them, you won't get an error.
'use strict'
const cloud = {
emoji: 'βοΈ'
}
// βοΈ cloud.emoji is now undefined
delete cloud.emoji
Moreover, the delete operator cannot be used to free up memory. In case you would like to free up the value of a variable, you can simply assign it to null
:
'use strict'
let cloud = 'βοΈ'
// βοΈ Correct way to free up a variable
cloud = null
Notice that the variable has been changed to let
. You cannot reassign values to a const
, otherwise, you will get another error: "Uncaught TypeError: Assignment to constant variable."
Tired of looking for tutorials?
You are not alone. Webtips has more than 400 tutorials which would take roughly 75 hours to read.
Check out our interactive course to master JavaScript in less time.
Learn More