/

HTML / CSS / JavaScript Tutorial

JavaScript Statement: const

[this page | pdf | back links]

In JavaScript, the const statement declares a constant. This is akin to a variable defined using a var statement, see here, or a let statement, see here, but with the variable being unable to be changed thereafter. Both the const and the var statements were introduced by ECMAScript 2015.

 

It is generally considered good practice to define variables as constants if they are not going to change, as it reduces the risk of them being accidentally overwritten.

 


NAVIGATION LINKS
Contents | Prev | Next | JavaScript Reserved Words


Desktop view | Switch to Mobile