Immutability interview questions
Practice 7 questions on immutability. Each runs in a real in-browser editor with Jest tests and a worked, diagram-backed solution.
7 questions
- MEDIUM
Deep Freeze
Recursively freeze an object and every nested object and array, making the whole structure deeply immutable.
25 minJavaScript - MEDIUM
Immutable Array Methods
Implement the ES2023 change-by-copy trio — toSorted, toReversed, and with — that copy an array instead of mutating it.
30 minJavaScript - MEDIUM
Normalized Entity Cache
Store entities flat by id, normalizing nested relations and merging updates immutably.
25 minJavaScript - MEDIUM
Streaming Chat Store Reducer
PREMIUMBuild a pure, immutable reducer that opens an assistant message, appends streamed deltas, and finalizes it.
25 minJavaScript - HARD
Immer produce()
PREMIUMImplement produce so mutating a draft proxy yields a new immutable state with structural sharing.
40 minJavaScript - HARD
Optimistic Mutation Manager
PREMIUMApply optimistic updates immediately and roll them back on failure, even with concurrent mutations.
40 minJavaScript - HARD
Persistent Immutable List
PREMIUMBuild an immutable list where every update returns a new version that shares unchanged nodes with the old one — structural sharing over a cons list.
40 minAlgorithms