vs — map, flatMap and compactMap

Higher order functions in Swift are fantastic additions. Although it’s introduce very early in Swift and many of us much familiar with how to use. When I delve more and started use them, I found a smart difference among them.

Javascript Array FlatMap Example | JS Array flatMap()

Javascript Array flatMap() is an inbuilt method that maps each element using the map function, then flattens the result into the new array.

JavaScript tutorial - array.prototype.flatMap()

Javascript Array flat() is an inbuilt method that creates a new array with all sub-array elements concatenated into it recursively up to the specified depth. It returns a new array with the sub-array elements concatenated into it.This tutorial covers array.prototype.flat() method. A multiple examples have been provided. This tutorial covers array.prototype.flatMap() method. This method is essentially a combination of map and flat methods. A multiple examples have been provided.