DEV Community

Charlotte Fereday
Charlotte Fereday

Posted on

2 1

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.

SurveyJS custom survey software

JavaScript UI Libraries for Surveys and Forms

SurveyJS lets you build a JSON-based form management system that integrates with any backend, giving you full control over your data and no user limits. Includes support for custom question types, skip logic, integrated CCS editor, PDF export, real-time analytics & more.

Learn more

Top comments (0)

SurveyJS custom survey software

JavaScript Form Builder UI Component

Generate dynamic JSON-driven forms directly in your JavaScript app (Angular, React, Vue.js, jQuery) with a fully customizable drag-and-drop form builder. Easily integrate with any backend system and retain full ownership over your data, with no user or form submission limits.

Learn more

👋 Kindness is contagious

If you enjoyed this article, consider showing your support with a ❤️ or sharing your thoughts in the comments!

Join a community of passionate developers!