flatMap is a method which a new array is returned by the application of a callback function on every array element and then taking the result and the nested array is flattened.

Example

const numArr = [2, 4, 6];

const newFlatArr = numArr.flatMap((x) => [x * 2]);

console.log(newFlatArr); //[4, 8, 12]