From the course: JavaScript Essential Training
Unlock the full course today
Join today to access over 24,000 courses taught by industry experts.
Const - JavaScript Tutorial
From the course: JavaScript Essential Training
Const
- [Instructor] The const statement defines a block scoped constant. From a scope perspective it works the same as the let statement, but a const is a constant meaning once it's defined, you cannot assign a new value to it. Let's look at our example again to see how this works here. Here we have our example in the status it was when we left it in the previous movie. Jumping over into the code, you can see we're now using lets instead of are so that we ensure that there is block scope and everything is working properly. But we still have this redefinition of a value down here. We redefined the color value to sky blue. Now let's see what happens if I change the lets at the top here to a const. Save. Check in the browser. And once again we have that problem where the right-hand box turns green. Only this time, the title is also black. So what is going on? Looking at the console we get a new Uncaught TypeError…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
-
-
-
-
-
Variables: Containers for everything2m 31s
-
(Locked)
Var3m 15s
-
(Locked)
Scope3m 37s
-
(Locked)
Let4m 34s
-
(Locked)
Const2m 58s
-
(Locked)
Data types3m 7s
-
(Locked)
Assignment vs. comparison4m 35s
-
(Locked)
Math operators6m 13s
-
(Locked)
Challenge intro: Calculate sales tax1m 35s
-
(Locked)
Solution: Calculate sales tax3m 30s
-
-
-
-
-
-