In JavaScript, variables, function expressions, and function declarations rise at the top of the area.
A function declaration defines a named function variable that does not require variable assignment.
And itβs important to know that all function declaration text gets a popup.
eg.
function outerFunction() { console.log(typeof functionDeclaration);
This is due to the fact that due to the lifting, the code works as follows:
function outerFunction() { function functionDeclaration() {
In your case, the declaration of the last function for foo rises at the top of the area, overriding all other function declarations. Therefore, it registers "b".
Variables and function expressions, however, can be raised without their assigned values.
eg.
function outerFunction() { console.log(functionExpression);
Performed more so
function outerFunction() { var functionExpression = undefined; console.log(functionExpression);
Prashant
source share