Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialDervis Findik
1,582 PointsWhat is the "middle"
Hi, just a little question ; when you said, a variable declared in the middle of a function is in fact automatically declared at the top of the function, what is the "middle" ? Is it an if block, a while block or a for block ?
Also the hoisting concern just JavaScript or also others programing languages ?
Thanks
4 Answers
James Barnett
39,199 PointsAlso the hoisting concern just JavaScript or also others programing languages
That's no a common thing as far as I know. I don't think Java, C++, Python or Ruby do that.
Jonathan Arbely
6,691 PointsIt means that the variable can be declared anywhere in the function itself. Say you have multiple lines of code in your function and declare a new var somewhere (in the middle) of all this code, it's like you had declared it on top of the function. So JS doesn't care where you define it, it only cares where you Change it's value. Another quick example. A new variable that is declared at the bottom of a function can be altered in the top.
Dervis Findik
1,582 PointsSo, in fact, the important thing in this video is about where the variable is affected by a value. Okey, thanks Jonathan !
Dervis Findik
1,582 PointsThanks James :)