Immutability refers to the property of a data value that prevents it from being modified after its creation. In JavaScript, primitive data types (e.g., strings, numbers) are immutable, while objects and arrays are mutable. Immutable data structures are often used to prevent unintended side effects in functional programming.
In JavaScript, all primitive types (string, number, boolean, null, undefined, symbol) are inherently immutable. You can reassign a variable to a new value, but you can never change the value itself.
Objects and arrays in JavaScript are mutable. Even if you declare them with const, you can still change their internal properties or elements. const only prevents you from reassigning the variable itself.
0-2 years experience
2-5 years experience
5-8 years experience
8+ years experience