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 trial
blueskyispink
2,997 PointsPartially Unrelated: A variable is defined as a returned value before a function is declared?
Hello!
This is unrelated to the do..while loop topic, but for the first time I see how a variable is declared as a returned value for a function BEFORE the function itself is declared.
A dummy structure:
var randNum = randomNumb(10);
function randomNumb(input) { }
In the previous lessons, I didn't see an order like this and I can't get my head around this.
Can someone please explain how is the code read by the interpreter in such case?
Thank you in advance!
1 Answer
martinjones1
Front End Web Development Techdegree Graduate 44,824 PointsI think the link below will best explain what is happening here, it's about a 5 minute read:
https://github.com/getify/You-Dont-Know-JS/blob/master/scope%20%26%20closures/ch4.md
blueskyispink
2,997 Pointsblueskyispink
2,997 PointsHello Martin,
Thank you very much for the resource, that explained it and even more :)
martinjones1
Front End Web Development Techdegree Graduate 44,824 Pointsmartinjones1
Front End Web Development Techdegree Graduate 44,824 PointsYour welcome, the You Don't Know JavaScript resource by Kyle Simpson is really good, I definitely need to read over that one again myself a couple of times :)