Use ES2019 Array.prototype.flat to Flatten Multidimensional Arrays

Share this video with your friends

Send Tweet

ES2019 introduces the Array.prototype.flat method. In this lesson, we'll flatten a multidimensional array using Array.prototype.reduce and Array.prototype.concat, and then refactor the code to do the same thing using the .flat method. We'll then use the depth parameter to flatten a 3 dimensional array.