ALO*_*low 20 apache-flex flex3 actionscript-3
我一直在寻找在ActionScript 3中清除数组.
有些方法建议:( array = [];内存泄漏?)
其他人会说: array.splice(0);
如果您有任何其他,请分享.哪一个效率更高?
谢谢.
Jas*_*son 29
array.length = 0或者array.splice()似乎最适合整体表现.
array.splice(0); 会表现得比 array.splice(array.length - 1, 1);
对于具有100个元素的数组(以ms为单位的基准,所需的时间越少):
// best performance (benchmark: 1157)
array.length = 0;
// lower performance (benchmark: 1554)
array = [];
// even lower performance (benchmark: 3592)
array.splice(0);
Run Code Online (Sandbox Code Playgroud)