JSFoo 2017

JSFoo is a conference about JavaScript and everything related.


Loop like an ES6 Native

Submitted by Lakshman Prasad (@becomingguru) on Thursday, 9 February 2017

Section: Full Talk Technical level: Intermediate Status: Under evaluation


One of the first things someone learns in programming is to loop, i.e. perform a sequence of steps on a set of elements. Any developer - beginner to advanced, writes atleast a few loops every hour. It’s ubiqutious nature merits a deep dive into the fundamentals of looping.

Let’s explore the various ways to loop in Javascript and it’s appropriate use cases. We explore loops in the imperative style and functional variants such as map and reduce. We look into the implementations of underscore.js, lodash and other such libraries that were often used with ES5.

ES6 comes bundled with many of these including the new generator syntax, which we will dig deep into, so your loops going forward can be both machine-efficient, and developer-friendly.


  • Basics
    • Various ways to loop
    • for … of loop and it’s comparison
    • for … of loop working on Maps, Sets, Args, DOM collections
    • Examples from other languages
    • “Array Like” and “Duck Typing”
    • Benefits with example - Unit Testing
  • Within the builtins
    • Iterators returned
    • Iterables consumed
    • spread operator
    • min, max etc.
    • Consistent interface
  • Under the hood - The Protocols
    • Iterator Protocol
    • Iterable Protocol
    • Examples
    • Custom Iterators/iterables
  • Generators
    • Builtin function
    • Lazy evaluation
    • Implements both iterator and iterable protocol
    • Keywords - yield, yield, function
  • Generators example
    • Example of a normal program
    • Comparison
    • Example of AJAX chaining
  • Generators Algorithm example
    • Recursive algorithm for fibonacci
    • Generator algo
    • Recursion algorithm for factors of a number
    • Generator algorithm
  • Your own generators in the real world
    • Examples

Speaker bio

Lakshman Prasad has been programming for a decade and finds ways to do efficiently, things that are often done. He works for a management consulting firm in developing technology solutions.


  •   Ganesh Gembali (@ggembali) 3 years ago

    Looking forward for the session :)

  •   Sandhya Ramesh (@sandhyaramesh) 3 years ago

    Hi Lakshman, can you please add slides to the proposal so that we have a better idea of your content and flow? Thanks.

Login with Twitter or Google to leave a comment