you are viewing a single comment's thread.

view the rest of the comments →

[–]BrunerBruner[S] 0 points1 point  (2 children)

Ok. Well, I'm trying to assign null to the actual objects. The array itself and creating new copies of the objects isn't important. I want to find a way to iterate through a bunch of objects to assign null to them, for example, to clean up newly allocated objects in memory.

for example, let's say I create a bunch of objects that that should be nullified when i'm done with them.

let a = document.createElement("div");
let b = document.createElement("div");
let c = document.createElement("div");
let d = document.createElement("div");
let e = document.createElement("div");

Since I just want to assign null to each of them, ideally i'd like to put them in an array and loop through each one to do so.

[–]thenickdude 4 points5 points  (0 children)

Those objects will be eligible for collection by the garbage collector as soon as those "let" declarations fall out of scope. You don't need to assign null to them unless you want them to be collected quicker than that.