The array.flatMap() method gives you the ability to map, but also to remove or even add new items in the resulting mapped array. By controlling the number of array items you return from the callback, you can do more than simple flattening. The method accepts a second, optional, argument indicating the this value inside of the callback.
2 Comments
Sort: