19 lines
813 B
Plaintext
19 lines
813 B
Plaintext
![]() |
== Why is this an issue?
|
||
|
|
||
|
Initializing a variable to `undefined` is unnecessary and should be avoided. A variable will automatically be set to `undefined` if you declare it without initialization, so the initialization code is redundant in this case.
|
||
|
|
||
|
[source,javascript]
|
||
|
----
|
||
|
var foo = undefined; // Non-compliant, replace with var foo;
|
||
|
let bar = undefined; // Non-compliant, replace with let foo;
|
||
|
----
|
||
|
|
||
|
|
||
|
== Resources
|
||
|
|
||
|
=== Documentation
|
||
|
|
||
|
* https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/undefined[MDN - undefined]
|
||
|
* https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/let[MDN - let]
|
||
|
* https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/var[MDN - var]
|
||
|
* https://developer.mozilla.org/en-US/docs/Glossary/Hoisting[MDN - hoisting]
|