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 Getting Started With ES2015 Defining Variables With let and const Using let with for Loops

Damien Bactawar
Damien Bactawar
8,549 Points

Would, "const = 43;" still be classified as "variable declaration"? It sounds more like "constant declaration". LOL!

Just a light-hearted question however one wonders about the decisions the ECMA make. If people structure their code correctly is block level scope something that you have to worry about? Are they making developers live easier? Actually I'm just joking. I'm sure it is progress. I'm too junior to be making these judgments.

2 Answers

Steven Parker
Steven Parker
231,269 Points

Well, first off, "const = 43;" isn't valid syntax. You'd need to have an identifier name between the keyword "const" and the assignment operator, something like "const answer = 43;"

But yes, this is still referred to as a variable. A mathematician would argue that it's a constant and not a variable, but in programming lingo, it's a "variable" that happens to be "immutable" (or it has the property of being "constant").

And block scope does indeed make development easier (or at least less error-prone) once you're used to using it.

Damien Bactawar
Damien Bactawar
8,549 Points

Thanks for sharing the knowledge.