Mutable vs immutable objects
Mutable objects can change in place; immutable objects require a new object for a changed value.
- List and dict are mutable
- str and tuple are immutable
- Matters for side effects and hashing
Mutable vs immutable objects
Tagged with objects
Mutable objects can change in place; immutable objects require a new object for a changed value.
Mutable vs immutable objects
A shallow copy copies the outer container; a deep copy recursively copies nested objects too.
Shallow copy vs deep copy
Objects can be created in several ways, and property access depends on whether the key is static or dynamic.
Object creation, object literals, property access, dot vs bracket notation, and object methods
Object helpers are useful for inspection and copying, but most built-in copy patterns are still shallow.
Object.keys, Object.values, Object.entries, Object.assign, spread with objects, shallow copy vs deep copy, Object.freeze, and Object.seal
JavaScript objects support descriptor-level control, computed accessors, explicit prototype creation, and different ways to check for properties.
Property descriptors, getters and setters, Object.create, hasOwnProperty, and the in operator
Spread expands values, rest collects remaining values, and destructuring pulls parts of arrays or objects into variables.
Spread operator, rest operator, and destructuring assignment in JavaScript