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 Introduction to jQuery DOM Manipulation Adding Content to the Page

parker keller
parker keller
6,539 Points

naming variables with var vs const/let?

is it still considered a best practice to name variables with var when working with jQuery? so far inmost other courses it seems as though we should mainly be focusing on const and let when creating variables, so I'm not sure if this video was just made prior to this change, or if var still works

1 Answer

jacksonpranica
jacksonpranica
17,610 Points

I'm going to go with the reasoning that the video was made before the let / const came out. I also had this thought during the whole jquery videos and I just continued to use let and const on my own. It didn't break the programs or anything so it should be fine.

Additionally, I'm a firm believe that let and const are the way to go as the const really is great when you want to make a variable you don't want to change. Sometimes accidents happen and it's good to have javascript catch a place when you wanted to assign a different variable but you accidentally assigned the const.

parker keller
parker keller
6,539 Points

Thanks Jackson, that's pretty much what I assumed. I've been naming with const/let and including things like arrow functions and other stuff introduced in prior classes from the js track and so far so good. Just wanted to check in case jQuery had some weird naming conventions