Understanding const with Arrays and Objects in Javascript


const prevents reassignment but allows modification of the object or array it holds.

Source Code

const arr = [1, 2, 3];
arr.push(4); // Allowed
console.log(arr); // [1, 2, 3, 4]
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments