Loading...
init();
const init = () => {
console.log('ready');
};init();
function init() {
console.log('ready');
}Function declarations are hoisted with their body; a const arrow is in the temporal dead zone until its line.
ReferenceError from using a let variable in its temporal dead zone.const before the line that defines it.let, const or class is used before its declaration line.const or let, not var, to avoid silent undefined reads.Yes, but they are not initialized. Accessing them before the declaration throws a ReferenceError (the temporal dead zone).
var declarations are hoisted and initialized to undefined; only the assignment stays in place.
Class declarations behave like let: they are hoisted but cannot be used before the declaration.