views:

97

answers:

3

I'm trying to empty an array containing my drawn coordinates when a button "clear" is pressed. When I call drawnDivs.clear(), I get an error that it is not a function. drawnDivs is certainly an array, and I have firebug console.logs printing things out. It's hosted here.

+4  A: 

Nope, it's not. But drawnDivs.length = 0 should work.

Jordan
This will work if it's a true array, and not just an array-like object.
thomasrutter
@thomasrutter. True but it will preserve references and any other addition properties and functions defined on the array.
Jordan
@Jordan yes, this is still the best solution overall. And to be honest, it would still work on array-like objects, it just wouldn't free any of the existing members from memory right away. So only a minor point really.
thomasrutter
+2  A: 

drawnDivs = [];

Mike Ruhlin
Be careful, since this will not modify other references to the object.
jleedev
+1  A: 

Answered here stackoverflow

subhaze