2.When we declare an array with const keyword we can access, change array elements, push, pop, shift, unshift array elements although we have studied that const keyword doesnot allow redeclaring and reassigning of a variable?
You can declare an array with
const. I wouldn’t use
var as it’s basically obsolete now, having been superseded by the other two.
const means that you cannot reassign the variable, but you can still modify the array.
constdeclaration creates a read-only reference to a value. It does not mean the value it holds is immutable—just that the variable identifier cannot be reassigned. For instance, in the case where the content is an object, this means the object’s contents (e.g., its properties) can be altered.
it means if i have an array
i can do something like:
but cannot do:
Yes, that is correct.