how to flatten array with reduce in javascript

JavaScript
let flattened = [[0, 1], [2, 3], [4, 5]].reduce(
  function(accumulator, currentValue) {
    return accumulator.concat(currentValue)
  },
  []
)
// flattened is [0, 1, 2, 3, 4, 5]
//note idx and sourceArray are optional
const sum = array.reduce((accumulator, element[, idx[, sourceArray]]) => {
	//arbitrary example of why idx might be needed
	return accumulator + idx * 2 + element 
}, 0);
Source

Also in JavaScript: