Immutability & Cloning

Reference vs copy vs deep clone vs immutable update — see which nodes are shared after each operation.

Object trees

Nested state with user, tags, and meta. Run an operation, then mutate b to see what leaks back into a.

Same reference (a === b) Shared nested node Newly created node Just mutated
Copy strategy
Mutate via b (test isolation)
const a = createState();
let b = a; // same reference — mutating b changes a
a (original) @0x1a2
b (copy) @0x1a2
Strategy: reference assignment a === b: true Shared nodes: all

Console