/*eslint no-undefined: "error"*/
var foo = undefined;
var undefined = "foo";
if (foo === undefined) {
// ...
}
function foo(undefined) {
// ...
}
当做这种判断时会报标题中的错误, 因为undefined
可以为重写, 所以这个判断是不提倡的, 可以这么写:
/*eslint no-undefined: "error"*/
var foo = void 0;
var Undefined = "foo";
if (typeof foo === "undefined") {
// ...
}
global.undefined = "foo";
详情见:
https://eslint.org/docs/rules/no-undefined