Visualising documentation: JavaScript array.flatMap
Charlotte Fereday
Posted on August 23, 2020
Today’s function is array.flatMap(), mdn description here.
FlatMap does two things:
- map() -> applies the test function to each element of the aray
- 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.
💖 💪 🙅 🚩
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
javascript JavaScript dumbed down Part three. control flow, basic functions, and interactions.
August 17, 2023