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

JavaScript

Rod R
Rod R
3,050 Points

scope of variables within a function

I'm confused about one of the questions following the video: 'Using constants with array and objects'. I understand the intent of the CONST variable but I thought variables declared within a function have a local scope, and it was a best practice to not reuse variable names to avoid confusion. I thought it was explained in a previous course that it was possible to reuse a variable name within a function because of the limited scope, but not a good practice. Does that not apply to CONST when its been declared globally?