Hacker News new | past | comments | ask | show | jobs | submit login

"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.




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.


memory complexity in JS translates into time complexity needed for GC cycles.


and again, you are arguing about time complexity, while I don't, but I guess we can now just call it a day...




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: