O'Reilly logo

Get Programming with JavaScript Next: New features of ECMAScript 2015, 2016, and beyond by JD Isaacks

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Lesson 5. Declaring constants with const

After reading lesson 5, you will

  • Understand what constants are and how they work.
  • Know when to use constants.

The keyword const stands for constant, as in never changing. Many programs have values that never change, whether by intention or by happenstance. Values declared with const, referred to as constants, have the same characteristics as those declared with let, which you learned about in the previous chapter, with the additional feature of reassignment being forbidden.

Consider this

Consider the following switch statement, which uses flags to determine what type of action is being performed. The uppercasing of ADD_ITEM and DEL_ITEM indicates that these are values that are never expected ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required