Const Variable with Array and Objects tutorial in JavaScript
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, shrink-to-fit=no">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Const Variable with Array and Objects JavaScript</title>
<script>
const a = [10, 20, 30];
// a = [40,50,60]; // We can not reassign "const" value
a[0] = 40; //we can reassign "const" value this way individually
a[1] = 50;
a[2] = 60;
console.log(a);
const b = {
name: "Ram",
age: 25
};
// b = {
// name: "Hello", //we can not reassign "const" value this way
// age: 34
// };
b.name = "Hello World"; //we can reassign "const" value this way individually
b.age = 22;
console.log(b);
</script>
</head>
<body>
</body>
.png)
Comments
Post a Comment