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
Frank Sun3,155 Points
I think in the video "for in " loop is missing the keyword "var"! Why does the loop still work?
in the video call "Using
for in to Loop Through an Object's Properties5:31
Actually Issac, that's incorrect.
Frank, you're right.
prop should have
var before it. If it doesn't in the video, it's probably the case that it was either (1) defined at some other point in the document or (2) the instructor just forgot.
It will run without
var to define variables. It's just best practice since if you don't use
var, then the variable is defined in the global scope (behind the scenes) and this can cause problems.