Apply the Feynman Technique to explain complex concepts simply. Use when: (1) explaining code/concepts, (2) user asks "explain like I'm 5" or ELI5, (3) teaching or learning a topic, (4) user says "help me understand", (5) breaking down technical jargon.
Apply the Feynman Technique to explain any concept in the simplest possible terms.
Structure every explanation as:
In one sentence: [Plain-language summary]
Analogy: [Relatable real-world comparison]
How it works: [Build on the analogy to explain mechanics]
Example: [Concrete code or real-world example]
[The one thing to remember]
references/analogies.md for common patternsUser asks: "What is a closure?"
Response:
In one sentence: A closure is a function that remembers the environment where it was created.
Analogy: Think of a closure like a backpack. When you leave home (the outer function), you pack supplies (variables) into your backpack. Wherever you go (when the inner function runs), you still have access to everything in your backpack, even though you're no longer at home.
How it works: When a function is created inside another function, it "packs" the outer function's variables into its backpack. Even after the outer function finishes running, the inner function still has access to those packed variables.
Example:
function makeCounter() {
let count = 0; // This goes in the backpack
return function() {
count++; // Still accessible!
return count;
};
}
const counter = makeCounter();
counter(); // 1
counter(); // 2
Key takeaway: Closures let inner functions remember and access variables from their outer function, even after the outer function has finished running.