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
Using the keyword `const` to create variables have a number of benefits including the ability to prevent the value from being reassigned.
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
This is often the best choice for
declaring variables.
0:00
Const is short for constant, meaning that
the value of the variable shouldn't change
0:00
it should remain constant.
0:05
For example const pi is equal to 3.14159.
0:07
Const let's you protects variables from
being overwritten by any stray assignments
0:12
in your code.
0:17
In other words,
once you create a constant,
0:18
you can't give it another value.
0:20
Let me show you what I mean.
0:23
If you want to follow along you can
open up the workspace on this page.
0:25
Open up pi.html, and
as you can see we've assigned
0:29
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