Array.prototype.flat() - JavaScript | MDN

The flat() method of Array instances creates a new array with all sub-array elements concatenated into it recursively up to the specified depth.