MJ
asked on
Best way to reset a global array?
I have a global multi-dimensional array. What is the best way to reset the array (clear out all the values from it)? The size will obviously change each time.
var aa ={};
aa.myArray = [];
//...array gets populated somewhere
aa.clearArray = function(){
// which is better
aa.myArray[];
// or
aa.myArray.length = 0;
// or
aa.myArray = null;
}
ASKER
leakim- I was reading that that method only creates a copy and can have pointer issues.
http://davidwalsh.name/empty-array
http://davidwalsh.name/empty-array
var aa = new Array();
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Open in new window