When reduce is performed on an empty array with an empty array set as its initial value, apparently a value can't be pushed to that initial empty array (pushing isn't possible), whereas it can when reduce is performed on an array with a null value. Why doesn't it work in the first scenario without the null value?
Why doesn't [] set as the initial value (the second parameter of reduce) count as an element?
For example, you can perform reduce on an empty array with 0 set as the initial value:
[].reduce((prev, curr) => prev + curr, 0) // 0
[].reduce((arr, curr) => {
arr.push('val')
return arr
}, []);
// []
[null].reduce((arr, curr) => {
arr.push('val')
return arr
}, []);
// ['val']