Heads up! To view this whole video, sign in with your Courses account or enroll in your free 7-day trial. Sign In Enroll
Well done!
You have completed Getting Started With ES2015!
You have completed Getting Started With ES2015!
Preview
In this video we'll review the benefits of the new ways for declaring variables.
This video doesn't have any notes.
Related Discussions
Have questions about this video? Start a discussion with the community and Treehouse staff.
Sign upRelated Discussions
Have questions about this video? Start a discussion with the community and Treehouse staff.
Sign up
In summary, constants are your first
option when declaring variables.
0:00
They're used to prevent reassignment bugs
and to help you debug your code faster.
0:05
Const variables have block level scoping.
0:10
A block of code is anything
between curly braces.
0:13
The let keyword is a great substituent for
0:16
var when you're wanting
to reassign a value.
0:19
For example, when you're
incrementing an index in a loop or
0:22
adding strings together.
0:26
This prevents errors
when using four loops and
0:27
adding dynamic functionality to web pages.
0:31
The usage of the var keyword
is not recommended anymore,
0:33
since there are a number of scoping
issues associated with the var keyword.
0:37
It's best to start of by
declaring variables with const and
0:42
then using let as and
when you need to re-assign variables.
0:45
I hope you've enjoyed this
workshop on const and let.
0:49
Now you can use these new ways to
declare variables to avoid the pitfalls
0:52
of programming JavaScript and
have better functioning code.
0:56
You need to sign up for Treehouse in order to download course files.
Sign upYou need to sign up for Treehouse in order to set up Workspace
Sign up