# Advanced JavaScript Objects
Objects in JavaScript go far beyond simple key-value storage once you get into destructuring, prototypes, and property behavior.
## Destructuring and Defaults
```javascript
const { name, role = "Student" } = user;
```
Destructuring with default values avoids repetitive `user.name`, `user.role` access and handles missing fields gracefully.
## Spread and Rest
The spread operator copies properties into a new object, commonly used for immutable state updates:
```javascript
const updatedUser = { ...user, role: "Instructor" };
```
This creates a new object rather than mutating the original — important in frameworks like React where mutation breaks change detection.
## Computed Property Names
```javascript
const key = "email";
const user = { [key]: "student@example.com" };
```
Useful when a property name is only known at runtime.
## Property Descriptors
`Object.defineProperty` lets you control whether a property is writable, enumerable, or configurable — the mechanism frameworks use internally to build reactivity systems.
## Prototypal Inheritance
Every JavaScript object has an internal link to a prototype object it inherits properties and methods from. This is different from classical inheritance in languages like Java, though `class` syntax in JavaScript is built on top of prototypes.
```javascript
class Course {
constructor(name) {
this.name = name;
}
}
```
## Object.freeze and Immutability
`Object.freeze` prevents modification of an object's properties, useful for enforcing immutable configuration objects.
## Conclusion
Understanding objects at this depth explains a lot of "magic" behavior in frameworks and libraries, and helps you write more predictable, bug-resistant code.
Back to Blogs
Advanced JavaScript Objects
Beyond basic key-value pairs — object destructuring, spread, property descriptors, and prototypal inheritance in JavaScript.
10 Aug 2026
6 min read