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 trialJesse Dispoto
Front End Web Development Techdegree Graduate 14,538 PointsWhy is Dave still using var to initialize variables? Shouldn't we be using let and const when initializing variables?
Learning a lot from this JS course. However, I have now switched over to using let and const when working with variables, not var. Why is Dave still using var? I would be a good idea to switch over to let and const now. Where these videos made before 2015? Should this be updated?
1 Answer
Michael Hulet
47,913 PointsJudging by the UI in the video, it looks a tad bit on the older side, but the video file's timestamp says that the file was created in April 2017 (let
and const
still weren't insanely well-supported back then iirc). However, even though it's 2019, the var
keyword isn't going anywhere, is still valid JavaScript, and still has its use cases. I'd argue that it's good to use let
and const
by default like you're doing now to keep scope clearer and cleaner, but if you want your variable to be hoisted, it's still just fine to use var