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 Loops, Arrays and Objects Tracking Data Using Objects The Object Literal

Should Objects also be declared using let or const?

Just to be sure. I have learned that var is obsolete for declaring variables or arrays. Is the same thing true for objects?

4 Answers

Wiktor Bednarz
Wiktor Bednarz
18,647 Points

It is widely accepted that var declaration shouldn't be used at all by this point. Const or let should be used for declaring ANY data type variables and even functions. You should be choosing which one to use based only on the lifecycle and scope of your variable. However if you want to get deeper into the topic, I'd suggest reading up this article:


Jason Anders
Jason Anders
Treehouse Moderator 145,858 Points

Just to add a note to Wiktor Bednarz response, you'll find that with ES6, objects are more and more being created using Classes. You can have a quick read on classes here.

That was a great question for the Community. Thanks for asking it! :)


Thank you for the question and the answer

Great question! Thanks for answers!