SyntaxError: applying the 'delete' operator to an unqualified name is deprecated
错误提示
SyntaxError: applying the 'delete' operator to an unqualified name is deprecated (Firefox) SyntaxError: Delete of an unqualified identifier in strict mode. (Chrome)
错误类型
SyntaxError
仅出现在严格模式下。
哪里出错了?
示例
在 JavaScript 中,普通变量是不能删除的,在严格模式下会报错:
js
"use strict";
var x;
// ...
delete x;
// SyntaxError: applying the 'delete' operator to an unqualified name
// is deprecated
要释放变量引用的内容,可以将变量值设置为 null
:
js
"use strict";
var x;
// ...
x = null;
// x can be garbage collected