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 Select a Page Element By Its ID

tal Shnitzer
PLUS
tal Shnitzer
Courses Plus Student 5,242 Points

what is the "const" keyword?

how is it different from "var"? why is it used in this program and not var?

2 Answers

Hello Tal

The const keyword is used when you don't want the identifier to be reassigned. Const doesn't replace var but you can use let interchangeably with var. Also Const and Let give more specific scope. Hopefully I was able to help you! Happy Coding

Jason Anders
MOD
Jason Anders
Treehouse Moderator 145,860 Points

Hi Tal,

The const keyword was introduced in ES2015. Treehouse does have an Introduction to ES2015 course. This course will cover all the changes to JavaScript with the ES2015 introduction.
There is also a a very quick (14 minutes) Workshop here that covers Defining Variables with Let and Const.

For now, I'd recommend at least doing the Workshop. Then if JavaScript is a path you are wishing to go down, the ES2015 course would be a next logical choice.

Keep Coding! :) :dizzy: