Array flatMap() method in JavaScript! - New in Chrome Update 69

preview_player
Показать описание

In this video we take a look at how to use flatMap() and how it compares to the regular map() method.

Support me on Patreon:

For your reference, check this out:

Follow me on Twitter @dcode!

If this video helped you out and you'd like to see more, make sure to leave a like and subscribe to dcode!
Рекомендации по теме
Комментарии
Автор

One really cool thing about the flatMap method is the ability to 1: remove elements, 2: change (or keep) elements, and 3: add elements, all in one loop iteration.

For 1: simply return an empty array.
For 2: simply return an array with the element and whatever transformation you want.
For 3: simply return an array with the current element, and then a comma and the new element you want to add.

So it’s like Array.map and Array.filter baked into one.👌🏻

dawid_dahl
Автор

Can you please create a playlist without the dom videos. The reason i ask is that your js all playlist is really long and it puts people off while also some of the videos are from the dom playlist. A seperate playlist containing only none dom & web develomment js videos would really help. Thank you

yamacode
Автор

How to sum more than two elements in an multi dimensional array using flatMap method? Thanks

razvanbugoi