Articles → JAVASCRIPT → Const Keywords In Javascript
Const Keywords In Javascript
Purpose
- You cannot redeclare the const variable.
- 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>