Visualising documentation: JavaScript array.flatMap

charlottebrf_99

Charlotte Fereday

Posted on August 23, 2020

Visualising documentation: JavaScript array.flatMap

Alt Text

Today’s function is array.flatMap(), mdn description here.

FlatMap does two things:

  1. map() -> applies the test function to each element of the aray
  2. flat() -> flattens the results, i.e. smooshes together any nested arrays into a new single level 'flat' array.

That's right, it's the same as doing array.map.flat(). So why use it? It's a bit more efficient.

I've done my own version of the docs with sketches together. Here’s the folder for array.flatMap. Check out the readme to see how you can run the examples.

💖 💪 🙅 🚩
charlottebrf_99
Charlotte Fereday

Posted on August 23, 2020

Join Our Newsletter. No Spam, Only the good stuff.

Sign up to receive the latest update from our blog.

Related