Javascript unset array

Richard Peers picture Richard Peers · Mar 21, 2010 · Viewed 32k times · Source

How do i unset an array in javascript? i just want to empty it - so it has nothing in it keys or anything

Answer

marcosbeirigo picture marcosbeirigo · Mar 21, 2010

you can assign a new array to it:

var array = ["element1","element2","element3"];
...
array = new Array();

OR

array = [];