Check out a free preview of the full JavaScript: The Hard Parts course:
The "Q&A: Const and Let" Lesson is part of the full, JavaScript: The Hard Parts course featured in this preview video. Here's what you'd learn in this lesson:

Will takes questions from students about Const and Let declarations.

Get Unlimited Access Now

Transcript from the "Q&A: Const and Let" Lesson

[00:00:00]
>> Will Sentance: Okay, let's have thumbs on this function. Everyone's thumbs out? You're gonna be very disappointed in a moment by the next function we see. Dave, do you wanna clarify?
>> Dave: There has been far and let.
>> Will Sentance: It's essentially, ES 2015 introduced us these two new ways to clear our labels, const and let.

[00:00:22] The reason in hard parts I just use var is because, for our purposes in our path, we're not too worried. But just know here's our fundamental rule. And it's not followed here, but we should. Here's our fundamental rule. We should use const for everything, objects, arrays, numbers, strings, const.

[00:00:42] Unless we know we are specifically gonna take what data's in there right now, the whole object, or the whole array, or the whole number, and throw it out. Replace it with a new object, array, or value. In which case we will use let. So that's the only rule, const all the time unless we know we are absolutely gonna fully reassign this data, in which case we can use let.

[00:01:03] So we should probably for output. There's a debate. We should probably for output there, use const. There's a debate about it, we should use const. I just use var and hot pots because it doesn't give us anything for what we're doing in our particular areas of hot pots.

[00:01:18] So for now just know when you see that let, const or var, the next word is gonna be a label. And then the thing on the other side of the equals sign is gonna be the data stored in that label. Make sense, Dave? All right,