05: Constants

Sometimes you need to create a variable that can never change. In programming this is usually called a "constant". A constant is more like a fact that should be the same value all the time. The concept of a constant is fairly new to JavaScript, so there are not too many guidelines on how to use them. I would say, use them sparingly until you figure out what works best. One place you will see them used is when you create functions in new JavaScript code.

The Code

{{ ork.js() }}

As you can see here the keyword const is used to create a constant. This means a variable cannot change, so if you look at lines 9 and 10, you will see they are commented out (meaning disabled). You should remove the comment in front of line 10 to see thet error message you get. You should watch me do this in the video as it is easier to see it being done than to read about it.

Learn JavaScript Today

Register today for the Beginner Basics course and get the new releases by just paying the difference. There's also special discounts for existing customers when new courses are released.


Still Not Sure? Check out more curriculum!