Skip to content

eslint/no-undefined Restriction

What it does

Disallow the use of undefined as an identifier

Why is this bad?

Example of bad code

javascript
var foo = undefined;

var undefined = "foo";

if (foo === undefined) {
  // ...
}

function baz(undefined) {
  // ...
}

bar(undefined, "lorem");

Example of good code

javascript
var foo = void 0;

var Undefined = "foo";

if (typeof foo === "undefined") {
  // ...
}

global.undefined = "foo";

bar(void 0, "lorem");

References

Released under the MIT License.