Advertisement

Iterable Sequences with Generators and Iterators

  • Raju Gandhi
Chapter

Abstract

Storing and manipulating data in collections in JavaScript is not only easy, but also elegant. However, iterating is another matter. Consider arrays. In order to iterate and fetch the elements of an array, we use contrived syntax like the for (let i = 0; i < array.length; i++) loop, or even worse, the for-in loop. But that’s not the end of it! Every so often we will have custom objects that might need iteration. We concede defeat, and build (or consume) a custom API (think array.forEach) just so we can get each element in a particular sequence.

Copyright information

© Raju Gandhi 2019

Authors and Affiliations

  • Raju Gandhi
    • 1
  1. 1.ColumbusUSA

Personalised recommendations