Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

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
220,450 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,326 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.

Owen McComas
Owen McComas
8,472 Points

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,869 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.