JS Coding Questions Logo
JS Coding Questions
#308💼 Interview💻 Code

Does the `const` variable make the value immutable

Advertisement

728x90

No, the const variable doesn't make the value immutable. But it disallows subsequent assignments(i.e, You can declare with assignment but can't assign another value later)

javascript
1const userList = [];
2
3userList.push("John"); // Can mutate even though it can't re-assign
4
5console.log(userList); // ['John']

Advertisement

Responsive Ad
🎯 Practice NowRelated Challenge

JavaScript Coding Exercise 52

Test your knowledge with this interactive coding challenge.

Start Coding

Advertisement

728x90
308of476