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
seth aruby
10,111 PointsWhy refer to const as a variable in the first place?
Since a const is not really variable?
2 Answers
Jennifer Nordell
Treehouse TeacherHi there, seth! Because you haven't linked a video or discussion, I can't say exactly where you saw/heard this. That being said constants are much like variables in that they reference a value held in memory. The big difference is that a true variable can be changed while a const can not. But both are still referencing a value held in memory. The name of a variable or constant is simply a label/alias to retrieve that value. The instructor may have misspoken and said variable when they meant constant. This happens to all of us, especially with things for which others substitute similar terms for each other. I see this also happen with the terms "argument" and "parameter". Semantically, they are very different, but even seasoned programmers use these interchangeably at times.
Hope this helps!
Richard Nesbitt
6,775 PointsI think the simplest answer to your question is this: What if you use it 500 times, and then need to change the value?
Many variables I see used on a daily basis, never change in the programming, but are referenced all over the place. Maybe constants would be more semantically appropriate, but they are defined at the start of the script so we can change them all at the same time.
seth aruby
10,111 Pointsseth aruby
10,111 PointsThank you for your explanation, Jennifer. Very helpful! Here's a link to the module I was looking at for your reference.
https://teamtreehouse.com/library/creating-unchanging-variables-with-const-2