Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

why does hoisting does not work in function expressions

// As per MDN
"Conceptually, for example, a strict definition of hoisting suggests that 
variable and function declarations are physically moved to the top of 
your code, but this is not in fact what happens. Instead, the variable 
and function declarations are put into memory during the compile phase, 
but stay exactly where you typed them in your code."

// Explanation
Therefore, in a function expression, actual function is a value assigned 
to a named variable. So this named variable is hoisted. Even if you 
have a named function assigned, it still will not be hoisted as it is 
not a declaration and will be created later.
  
  
 
PREVIOUS NEXT
Tagged: #hoisting #work #function #expressions
ADD COMMENT
Topic
Name
9+7 =