Hoisting

JavaScript Variables — let, const, var, Scope, and Hoisting
JavaScript Variables — let, const, var, Scope, and Hoisting
A modern, ES6+ first guide to declaring variables in JavaScript — when to use const, when to use let, why var still exists, and how scope, hoisting, and the temporal dead zone actually work.