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

Example




<!DOCTYPE html>
<html lang="en" xmlns="http://www.w3.org/1999/xhtml">
   <head>
      <meta charset="utf-8" />
      <title></title>
      <script>
         const pi = 3.14;
         
         // This code will give error
         pi = 3.1416;
         
         const pi2;
         
         // This code will give error
         pi2 = 3.1416;
      </script>
   </head>
   <body>
   </body>
</html>





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

Query/Feedback


Your Email Id
 
Subject
 
Query/FeedbackCharacters remaining 250