As3 - How to clear an array efficiently?

ALOToverflow picture ALOToverflow · Feb 10, 2010 · Viewed 39.8k times · Source

I've been looking to clear an array in ActionScript 3.

Some method suggest : array = []; (Memory leak?)

Other would say : array.splice(0);

If you have any other, please share. Which one is the more efficient?

Thank you.

Answer

Jason picture Jason · Feb 10, 2010

array.length = 0 or array.splice() seems to work best for overall performance.

array.splice(0); will perform faster than array.splice(array.length - 1, 1);