<!doctype html>
<head>
<style>
/* CSS comes here */
</style>
<title>const Statement</title>
</head>
<body>
<h2>Understand use of const in JavaScript</h2>
<script>
// global scope
const x = 200
// block scope
{
const x = 10
document.write("Inside the block:"+x)
}
// function scope
function show() {
const x = 20;
document.write("<br>Inside the function:"+x)
}
show();
document.write("<br>Global x:"+x)
x = 100 // TypeError: Assignment to constant variable.
document.write("<br>Global x:"+x)
</script>
</body>
</html>