I remember learning variable hoisting when I was learning JavaScript for the first time. From MDN docs:
Because variable declarations (and declarations in general) are processed before any code is executed, declaring a variable anywhere in the code is equivalent to declaring it at the top. This also means that a variable can appear to be used before it's declared. This behavior is called "hoisting", as it appears that the variable declaration is moved to the top of the function or global code.
I was teaching a friend about hoisting in JavaScript, and that popped a question in my mind.
In what else languages did you come across this hoisting behaviour? I’m pretty sure Python doesn’t have this!
j
stuff ;)
compileroptimizations.com/category/hoisting.htm like this ? :)