News for hackers. Stuff that matters.
Re:How to use array reduce for more than just numbers by c-smile on Sunday June 02, 2019 @11:59AM (#20076230)
"new object is created in each iteration"

Not just created, but properties are being populated one by one.

"can be garbage collected"

And what do you think is computational complexity of garbage collector?

Yes, memory allocation in JS (GCable environment) is cheap. But garbage collection per se is not, it is at least O(N) complex.

Re:How to use array reduce for more than just numbers by Rockslide on Sunday June 02, 2019 @01:25PM (#20076744)
I never claimed garbage collection was free, but the point was memory complexity and not computational complexity. So claiming that the implementation would be O(n * n) in terms of memory complexity still doesn't make sense to me.
Re:How to use array reduce for more than just numbers by c-smile on Sunday June 02, 2019 @11:56PM (#20080305)
memory complexity in JS translates into time complexity needed for GC cycles.
Re:How to use array reduce for more than just numbers by Rockslide on Monday June 03, 2019 @03:39AM (#20081168)
and again, you are arguing about time complexity, while I don't, but I guess we can now just call it a day...