Skip to content

@flying-sheep /gist:5627847
Created

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Firefox Generator/Iterator glossary

Glossary

Iterator
Object with .next(), .send(obj) and .close() methods.

It is iterable via for...of and for...in loops. Both ways act the same, i.e. call .next() repeatedly until it throws a StopIteration.

Generator expression
Iterator created via e.g. (x*2 for (x of array)).

  • Can be assigned to a variable (⇒ Generator comprehension),
  • used in function call braces to create arguments (e.g. MyListClass(x for (x of myArray))),
  • or used with brackets instead of braces, which makes it an Array comprehension (e.g. var keys = [x for (x in myObject)])

Generator function
Iterator factory created via e.g. function g() { yield 1; yield 2 }.

A call to g() will return a new Iterator.

ECMA 6 Iterable
An object with an .iterator(…) method that returns a generator function. It is iterable via for...of.

JavaScript 1.7 Iterable
An object with an .__iterator__(…) method that returns a generator function. It is iterable via for...in.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.