Immutability
ELI5 — The Vibe Check
Immutability means once you create something, you can't change it — like writing in pen. Want to make a change? Create a new copy with the change. It sounds wasteful but it prevents a TON of bugs because nothing can change behind your back.
Real Talk
A programming principle where data cannot be modified after creation. Instead of mutating existing values, new values are created with the desired changes. Immutability eliminates a class of bugs related to shared mutable state, simplifies concurrency, and enables features like undo/redo and time-travel debugging.
Show Me The Code
// Mutable (dangerous)
const arr = [1, 2, 3];
arr.push(4); // mutates original
// Immutable (safe)
const arr = [1, 2, 3];
const newArr = [...arr, 4]; // new array
// Object spread for immutable updates
const user = { name: 'Alice', age: 30 };
const updated = { ...user, age: 31 };
When You'll Hear This
"React state must be treated as immutable — never mutate, always create a new object." / "Immutable data structures make concurrency trivial because there's no shared mutable state."
Related Terms
Functional Programming
Functional programming is like cooking with strict rules: no shared bowls, no side dishes contaminating each other, and every dish must be exactly reproduc...
Redux
Redux is the granddaddy of React state management that makes you write three files to update one number. Actions, reducers, dispatchers, oh my!
Referential Transparency
Referential transparency means you can replace a function call with its return value and nothing changes.
State
State is a component's memory — data that can change over time and causes the UI to update when it does. Think of a counter: the number is state.