Bummer! This is just a preview. You need to be signed in with a Basic account to view the entire video.
Overview1:00 with Andrew Chalkley
In this video we'll review the benefits of the new ways for declaring variables.
In summary, constants are your first option when declaring variables.
They're used to prevent reassignment bugs and to help you debug your code faster.
Const variables have block level scoping.
A block of code is anything between curly braces.
The let Keyword is a great substitute for
var when you're wanting to reassign a value.
For example, when you're incrementing an index in a loop or
adding strings together.
This prevents errors when using for
loops and adding dynamic functionality to web pages.
The usage of the var Keyword is not recommended anymore.
Since there are a number of scoping issues associated with the var Keyword it's
best to start off by declaring variables with const and
then using let as and when you need to resign variables.
I hope you've enjoyed this workshop on const and let.
Now, you can use these new ways to declare variables to avoid the pitfalls
You need to sign up for Treehouse in order to download course files.Sign up