How to Declare a Constant Variable in JavaScript ?
Last Updated :
29 Jan, 2024
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);
|
Share your thoughts in the comments
Please Login to comment...