Link to home
Start Free TrialLog in
Avatar of MJ
MJFlag for United States of America

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;

}

Open in new window

Avatar of leakim971
leakim971
Flag of Guadeloupe image

what about :
aa.myArray = [];

Open in new window

Avatar of MJ

ASKER

leakim- I was reading that that method only creates a copy and can have pointer issues.

http://davidwalsh.name/empty-array
var aa = new Array();
ASKER CERTIFIED SOLUTION
Avatar of leakim971
leakim971
Flag of Guadeloupe image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial