fibonacci-generator.js
function* fibGen(count) {
let a = 0, b = 1;
for (let i = 0; i < count; i++) {
yield a;
[a, b] = [b, a + b];
}
}
const first8 = [...fibGen(8)];
first8;
What to watch
Each yield appears in the execution log; the returned iterator shows its values, and spread collects them into an array.
Reading fibonacci generatoron a page only gets you so far - code is a process, and the process happens at runtime where you can't normally see it. In NeonFlow, this exact program runs step by step: every call opens a frame, every branch picks a path, and every value moves through memory in front of you. That's the fastest way to actually understand how fibonacci generator works.
Run fibonacci generator yourself
Open NeonFlow, paste this code (or any of your own), and scrub through it one step at a time.
Open NeonFlow