How to Declare a Constant Variable in JavaScript ?
In JavaScript, you can declare a constant variable using the const
keyword. The const
keyword is used to create variables whose values should not be reassigned once they are initially set.
Example: Here, pi
is a constant variable, and its value is set to 3.14
. Once a value is assigned to a constant variable using const
, you cannot change that value throughout the rest of the program.
Javascript
const pi = 3.14; console.log(pi); |
Output
3.14