3 ms·
"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 i
by c-smile 7y ago
"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.
- Rockslide 7y agoI 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.