Question · JavaScript and TypeScript course · Module 12: Functional Programming

Array.flatMap() vs Array.map()

What does Array.flatMap() return compared to Array.map()?

Answer options

  • First maps, then flattens the result by one level of nesting
  • Works identically to map(), but is faster
  • Returns a value instead of an array
  • Always returns an array of objects instead of an array of primitives

You can check the correct answer by solving this task in the CodeWorlds game.