Module 17 · Performance, Memory, Debugging and the Interview Output Puzzles
What Each Operation Costs, and When to Optimise at All
ProReading
Rafi runs a small online shop. His order page was fine with 200 orders. With 20000, it freezes for seconds. Nothing in his code looks slow: there is no loop inside a loop, only a few tidy lines with filter and indexOf. Yet one of those tidy lines hides a second loop, and that is the whole problem.
Checking what this lesson needs for you…
What is inside What Each Operation Costs, and When to Optimise at All
- Big-O in one page
- Array index and length
- push and pop
- shift and unshift
- splice in the middle
- includes, indexOf and find against Set.has
- Map.get against an object key
- Strings: +=, slice and indexOf
- sort
- The nested-loop trap
- All the costs on one page
- When to optimise, and when not