JS: “function” (keyword) name hoisting

By Xah Lee. Date: . Last updated: .

Function Declaration Hoist Name and Value

for functions defined by the keyword function, there are these complex issues:

Compare:

console.log(ff());
// prints
// 3

function ff() {
 return 3;
}
console.log(gg());

var gg = function gg() {
 return 3;
};

// error: Uncaught (in promise) ReferenceError: Cannot access 'gg' before initialization