Does JavaScript promise create memory leaks when not rejected or resolved?
I'm in a situation where I need execute async functions in "parallel", and continue program execution with the best result. Thus I wrote something like this : var p = []; for (var i = 0; i < 10; ++i) (function (index) { p.push(new Promise(function (resolve, reject) { setTimeout(function () { var success = Math.random() > 0.7; console.log("Resolving", index, "as", success ? "success" : "failure"); success && resolve(index); }, Math.random() * 5000 + 200); })); })(i); Promise.race(p).then(function (res) { console.log("FOUND", res); }).catch(function (err) { console.log("ERROR", err); }); Now, I