re: Much needed filterMap in JavaScript VIEW POST

FULL DISCUSSION
 

There is the flatMap method that does exactly that filter + map :)
this method not only lets you dynamically filter the array, but it also gives the ability to add elements to the array dynamically.

developer.mozilla.org/en-US/docs/W...

// example
someArray.flatMap((element) => {
  if(element.isNotNeeded){
    return [];
  }

  return [ element.someProperty ];
})
code of conduct - report abuse