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 Traversal Why We Traverse the DOM

Gaurav Yadav
Gaurav Yadav
5,047 Points

Should we use var or const/let in jQuery?

In the video, the teacher has used

var students = [
    {name : "abc"},
    {name : "def"},
    {name : "ghi"}

So should we use const instead of var? Is var still used?

1 Answer

Valeshan Naidoo
Valeshan Naidoo
27,008 Points

Use const and let instead of var. It's now standard practise and is much better. Use const with all variable names and you can always change a variable to let afterwards if you find that it's going to be a re-writable variable. There is a workshop about const and let application.