Review

ES6 introduces several new features that aid in code organization:

  • Iterators provide sequential access to data or operations. They can be consumed by new language features like for..of and ....
  • Generators are locally pause/resume capable functions controlled by an iterator. They can be used to programmatically (and interactively, through yield/next(..) message passing) generate values to be consumed via iteration.
  • Modules allow private encapsulation of implementation details with a publicly exported API. Module definitions are file-based, singleton instances, and statically resolved at compile time.
  • Classes provide cleaner syntax around prototype-based coding. The addition of super also solves tricky issues with relative references in the [[Prototype]] chain.

These new tools should be your first stop when trying to improve the architecture of your JS projects by embracing ES6.