Bummer! This is just a preview. You need to be signed in with a Basic account to view the entire video.
Reviewing let and const1: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 substituent 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 four 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 of by declaring variables with const and
then using let as and when you need to re-assign 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