DEV Community

Discussion on: Javascript Hoisting

Collapse
robencom profile image
robencom

so in a nutshell: only variable declarations are hoisted (elevated to the top of the code) to not throw any ERRORS, but of course these variables are undefined; but when it comes to functions, if they are not arrow functions or function expressions, then the function is TOTALLY hoisted.

Collapse
copleykj profile image
Kelly Copley

This is because all declarations are hoisted. Function declarations are no different than variable declarations, memory must be reserved for them as well.

Collapse
naveenchandar profile image
Naveenchandar Author

Exactly.

Collapse
robencom profile image
robencom

Great article really. I was recently asked this question in a interview, I blabbered something and even the interviewer didn't understand what hoisting really is, so my answer passed :D but now I know what to say.. MANY THANKS!

Thread Thread
naveenchandar profile image
Naveenchandar Author

😊😊😊.