SyntaxError: 对非限定名称应用“delete”运算符已弃用
消息
SyntaxError: Delete of an unqualified identifier in strict mode. (V8-based) SyntaxError: applying the 'delete' operator to an unqualified name is deprecated (Firefox) SyntaxError: Cannot delete unqualified property 'a' in strict mode. (Safari)
错误类型
SyntaxError
仅在 严格模式 中。
哪里出错了?
示例
释放变量的内容
尝试删除普通变量会在严格模式下抛出错误
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