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 JavaScript Foundations Variables Shadowing

Bad practice

I'm not a fan of languages that don't strictly type, and I understand your discussion of scope, but I don't think it's helpful to offer a lesson where you deliberately suggest a bad practice like using the same variable name. Not useful.Not helpful.

1 Answer

geoffrey
geoffrey
28,736 Points

I've followed most of the JS course and honestly, maybe you have already some experience with development. But as a noob on my side, this video was helpful. It explains clearly what's shadowing, something I didn't know as noob and thanks to it, I now know it can occurs with Javascript...

Eric Carey
Eric Carey
6,820 Points

Agreed. Prior to TreeHouse I studied Ruby quite a bit on my own, but I'm still fairly new to programming. Since Ruby handles global variable declarations differently, I found the overview of this JS quirk quite helpful.

If anything, perhaps it could be more explicitly stated in the video that this is very much "DON'T DO THIS!" territory.