Didn't know "var" was outdated. Good stuff, thanks!
When switching to let/const, bear in mind the difference in scope:
var is function-scoped:
(function () {
var x = 1;
})();
var x === undefined
let/const are block-scoped: if (true) {
var x = 1;
let y = 1;
const z = 1;
}
x === 1
y === undefined
z === undefinedif(..) { ... huge block of code .. var foo = 1; }
Means I do not have to scroll back and forth to declare and set the variables at different places.
typeof myFn === 'function'; // true
function myFn() { }"In ECMAScript 2015, let bindings are not subject to Variable Hoisting, which means that let declarations do not move to the top of the current execution context."
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Refe...