Constants containing arrays and objects work in an interesting way. JavaScript does not allow you to change the values of these constants, but you can change the properties of objects and the values of array elements.
Let's look at examples. Suppose we are given such an object:
const obj = {a: 1, b: 2, c: 3};
Let's try to write something else into it:
obj = 123; // error
Let's try to write another object into a constant:
obj = {x: 1, y: 2, z: 3}; // error
However, if we try to change the property of the object, then it works:
obj.a = '+'; // it works!
What will be the result of executing the following code:
const arr = ['a', 'b', 'c'];
arr[1] = '!';
console.log(arr);
What will be the result of executing the following code:
const arr = ['a', 'b', 'c'];
arr = [1, 2, 3];
console.log(arr);
What will be the result of executing the following code:
const arr = ['a', 'b', 'c'];
arr = ['a', 'b', 'c'];
console.log(arr);