DEV Community

Discussion on: A toddlers guide to memory leaks in Javascript

5bentz profile image
5bentz • Edited on

result = newData.reduce((p,r) => arrayAddFirst(r, p), []);
virtual hug if you can guess what it does

I'd say it reverses the order of the elements.

for(var j = 0; j < i; i++)
Notice how easy it is to see it will run n * (n+1) / 2 times

To me, it is easy to see it is an infinite loop :'D
With j++, it would run 0 + 1 +...+ n-1 times. Thus, n*(n-1)/2 times.

This article is a simple tutorial to memory leak & its analysis in a web browser =) I used Firefox 60 instead of Chrome without any hassle.

Thank you !