ES2015 code snippets using pure functions

Functional code snippets for commonly used utility methods using ES2015

Posted by Aditya Pratap Singh on May 14, 2016
  1. map(): Function to map a list to another. It uses ES2015 de-structuring and spread operator (...) to access the elements of the list

  2. len(): Function to recursively calculate the length of a list. It uses ES2015 de-structuring and spread operator (...) to access the elements of the list

  3. range(): Pure function to get the range of values from start to end. This uses the new Array.from() method in ES2015 which accepts a array-like object as first parameter and optional map() function as second parameter