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 trialAbir Ahmed
Courses Plus Student 8,616 PointsWhy by removing "var" of the functions make functions look for a variable in Global Scope?
I mean how will function know if " person = 'lilah' " is a variable as there is no indicator that " person = 'lilah' " is a variable?
1 Answer
Daryl Carr
18,318 PointsI think its just a default. The global scope is basically a property on the global object so as you have assigned it without the var keyword, its default is to add it as a property of the global object... As for knowing, there is an assignment operator, the = so it js thinks you are saving a value to something, aka a variable.
Abir Ahmed
Courses Plus Student 8,616 PointsAbir Ahmed
Courses Plus Student 8,616 PointsThanks, that equal (=) sign makes sense :D