Queries & Responses for 22 October 2005

clear an array javascript
Y’all overthink this stuff. Just re-‌assign it an empty array.
var array = [ 'lots', 'of', 'stuff'];
array = []; // nuthin'
Or if you’re bent on really emptying it—especially while doing something with the elements as you’re stripping them out—you could do something like this–
var array = [ 'one', 'two', 'three' ];
while ( array.length > 0 ) { array.shift(); }
[close] Permanent link · http://querylog.com/q/clear+an+array+javascript

Suggested HTML for linking:
Link preview: clear an array javascript
22 October 2005 · Internet & computing
The page found by the original query:
Randomize arrays in JavaScript with the Fi…
Browse by the page—15 Q&R each
« previous | more »