Hoisting is not about physically moving code to the top , but rather about how javascript allocates memory for variables and functions during memory creation phase
- you can call function before its declaration in the code because entire function is available in code from start.
- But function expression can't be hoisted
- but trying to access variable before its declaration will result in "undefined"
what javascript sees?
Q) why it gives us a impression that declarations are move to top of their scope but its actually not ?
- because only declaration is processed before any code is executed not a initialization.
Top comments (0)