Articles → JAVASCRIPT → Const Keywords In Javascript

Const Keywords In Javascript






Purpose




  1. You cannot redeclare the const variable.
  2. You cannot reassign the value of the const variable
  3. You must assign the value to the constant at the time of declaration.

Example




<script>
         const pi = 3.14;

         // This code will give error
         pi = 3.1416;

         const pi2;

         // This code will give error
         pi2 = 3.1416;
</script>

Try It




Posted By  -  Karan Gupta
 
Posted On  -  Wednesday, July 28, 2021

Query/Feedback


Your Email Id
 
Subject
 
Query/FeedbackCharacters remaining 250