Open In App

How to Declare a Constant Variable in JavaScript ?

Last Updated : 29 Jan, 2024
Improve
Improve
Like Article
Like
Save
Share
Report

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

Like Article
Suggest improvement
Share your thoughts in the comments

Similar Reads