Disallow Initializing to undefined (no-undef-init)
undefined. For example:
var foo; console.log(foo === undefined); // true
It’s therefore unnecessary to initialize a variable to
undefined, such as:
var foo = undefined;
It’s considered a best practice to avoid initializing variables to
This rule aims to eliminate variable declarations that initialize to
The following patterns are considered warnings:
var foo = undefined; let bar = undefined;
The following patterns are not warnings:
var foo; let bar;
When Not To Use It
If you want to allow initialization of variables with
undefined, then you can safely turn this rule off.
This rule was introduced in ESLint 0.0.6.