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 and the DOM (Retiring) Getting a Handle on the DOM A Simple Example

SeHyun Choi
SeHyun Choi
3,441 Points

What is const?

I just finished JavaScript loops array object course and I started this course because it right below it. I don't think I learned about const yet. Did I skip a course? Which course should I take before learning DOM?

4 Answers

Steven Parker
Steven Parker
231,275 Points

You may have started your training with courses developed prior to the ES2015 version of JavaScript.

You can catch up on the newer features with the Getting Started With ES2015 course or the more extensive Introducing ES2015 course.

Swan The Human
seal-mask
.a{fill-rule:evenodd;}techdegree
Swan The Human
Full Stack JavaScript Techdegree Student 19,338 Points

They should really add this course as an update in the JS track so people aren't confused as they move along. Some people may not search the questions and see this comment. Also I'm not sure if they add update courses for every time a new es comes out but they should do that as well.

Great question! a lot of those videos you have been watching so far were recorded before the new syntax came out. 'const' and 'let' are both newer ways used to declare a variable just like var. The details of how they differ and the reasonings for their implementation are explained in this course

Michael Hulet
Michael Hulet
47,913 Points

As others have pointed out, the videos you watched were probably recorded before ES2015 was popular, and you should totally go back and watch those that the others recommended. To answer your question directly, though, it's like a variable, but you can't change its value after you define it. In other words, its value is guaranteed to be constant. For example, running this code:

const something = 1;
something = 2;

will result in this error:

TypeError: Attempted to assign to readonly property.
SeHyun Choi
SeHyun Choi
3,441 Points

Thank you everyone for your help.