Tag view

#generators

Cross-subject tag search for related interview cards.

Clear

Results update as you type. Press / to jump straight into search.

Tagged with generators

2 cards

Python Hard Theory

Iterable vs iterator, custom iterators, generators, and `send`/`throw`/`close`

An iterable can produce an iterator, an iterator yields values one at a time, generators are a compact way to build iterators, and advanced generator methods can push values or exceptions back in.

  • Iterables and iterators are not the same
  • Generators implement the iterator protocol for you
  • `send`, `throw`, and `close` control generator execution

Iterable vs iterator, custom iterators, generators, and `send`/`throw`/`close`

JavaScript Medium Theory

Iteration in JavaScript: for, while, do while, for...of, for...in, iterables, iterators, generators, and yield

JavaScript supports several loop forms, plus iterator and generator protocols for custom iteration behavior.

  • `for...of` iterates values
  • `for...in` iterates enumerable property keys
  • Generators pause and resume with `yield`

Iteration in JavaScript: for, while, do while, for...of, for...in, iterables, iterators, generators, and yield