DEV Community

Discussion on: Polyfill of Reduce

Collapse
 
shadowtime2000 profile image
shadowtime2000

Imagine you do this:

for (const i in myArray) {
console.log(i);
}
Enter fullscreen mode Exit fullscreen mode

this would be the output:

someElem1
someElem2
myReduce
Enter fullscreen mode Exit fullscreen mode

This is another basic snippet of code that has been shared around the internet a bit and you also didn't explain how it works.