Copy link to clipboard
Copied
What is the best way to clear an array? (performance and resources)
array.length = 0;
array = [];
array.splice(0);
array.length=0;
Copy link to clipboard
Copied
array.length=0;
Copy link to clipboard
Copied
If i use something like this:
arr = new Array();
some code
.
.
.
arr = new Array()
The variable arr won't be replaced faster in the memory with this new one?
Copy link to clipboard
Copied
that's creating a new array which is extra work, and it's adding an array to the objects that flash will gc, and that's extra work.
assigning the length to 0 is the most efficient way to clear an array.
Copy link to clipboard
Copied
Thanks.
Copy link to clipboard
Copied
you're welcome.
Find more inspiration, events, and resources on the new Adobe Community
Explore Now