The transpiled Array.reduce only accepts two arguments (source array and callback). This is how it's transpiled:
var _reduce = function _reduce(array, callback)
The following code will not run correctly as it discards the initial value:
const foo = [1, 2].reduce((prev, curr) => {
prev.push(curr + 1)
return prev
}, [])
Transpiled code:
(function () {
// prev.push is not a function
var foo = _reduce([1, 2], function (prev, curr) {
prev.push(curr + 1)
return prev
}) // no initial value
})()
The transpiled
Array.reduceonly accepts two arguments (source array and callback). This is how it's transpiled:The following code will not run correctly as it discards the initial value:
Transpiled code: