Avoid chain variable assignments in JavaScript
Chaining variable assignments may seem fancy but have unintended consequences associated with it. During chaining of variable assignments, implicit global variables are created which results in polluting the global namespace.
js
// bad(function example() {let x = y = z = 1;// JavaScript interprets this as// let x = ( y = ( z = 1 ) );// The let keyword only applies to variable x, variables y and z become// global variables and thus polluting global namespace.}());console.log(x); // throws ReferenceErrorconsole.log(y); // 1console.log(y); // 1// good(function example() {let x = 1;let y = x;let z = y;}());console.log(x); // throws ReferenceErrorconsole.log(y); // throws ReferenceErrorconsole.log(z); // throws ReferenceError