Functor
ELI5 — The Vibe Check
A functor is a box you can map over. Array? Functor. Optional? Functor. Promise? Functor. If you can apply a function to what's inside without unwrapping the box, congratulations — you've been using functors all along.
Real Talk
A type F
Show Me The Code
// Array is a functor: .map() applies a function inside the 'box'
[1, 2, 3].map(x => x * 2); // [2, 4, 6]
// Option/Maybe is a functor
const name = user?.profile?.name; // mapping through optional chain
When You'll Hear This
"Every time you call .map() on an array, you're using it as a functor." / "Functors are simpler than monads — if you understand Array.map, you understand functors."
Related Terms
Array
An array is a list of things in order, like a numbered row of boxes. Box 0 holds the first item, box 1 holds the second, and so on.
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...
Monad
A monad is a design pattern for chaining operations that have extra 'context' — like maybe-empty values, async results, or errors.
Pattern Matching
Pattern matching is like a super-powered switch statement that can look inside data structures and pull out the parts you need.