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 Defining Variables with let and const!
You have completed Defining Variables with let and const!
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 substitute 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 for
0:27
loops and
adding dynamic functionality to web pages.
0:30
The usage of the var Keyword
is not recommended anymore.
0:34
Since there are a number of scoping issues
associated with the var Keyword it's
0:37
best to start off by declaring
variables with const and
0:42
then using let as and
when you need to resign 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