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 trialMichael Stedman
Full Stack JavaScript Techdegree Student 13,838 PointsStill using the "var" keyword?
Just prior to this "workshop", there was a workshop titled, "Defining Variables With let and const." In that series of videos, it was said that there is no reason to use the var
keyword anymore as using the const
keyword prevents reassignment of the variable, and using let
for the keyword is much better than using the old way of using var
.
Of course, that is paraphrasing what Andrew Chalkley was saying in the video. In this video, right as he is starting to change the first function declaration to a function expression, he is using the keyword var
.
Was this video created before the shift from using var
to using let
and const
? Or did I somehow misunderstand what he said in the previous workshop about not using the var
keyword anymore when assigning variables? Another possibility I just thought of is do the let
and const
keywords not work when with functions?
1 Answer
Andrew Chalkley
Treehouse Guest TeacherThe subtly is if you're only supporting modern browsers only then yes – also if you're using a transpiler like babel yes too. Most professional environments will have a transpile step.
Michael Stedman
Full Stack JavaScript Techdegree Student 13,838 PointsMichael Stedman
Full Stack JavaScript Techdegree Student 13,838 PointsEDIT SINCE I FINISHED THE VIDEO
Okay.... Hahaha, I'm an idiot. I should have just finished the video instead of just asking the question as soon as it popped up in my mind. Pretty much immediately following where I paused the video to type my above question, right at 2:30 in the video, Andrew Chalkley does bring up the fact that we are now using ECMA 2015 and starts diving into the
const
thing.Lol so, disregard the question unless anyone has some added input that would be useful to learn.