Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is JavaScript's array.clear() not a function? [duplicate]

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.

like image 432
Nona Urbiz Avatar asked Oct 26 '10 03:10

Nona Urbiz


2 Answers

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

like image 181
jordanbtucker Avatar answered Oct 03 '22 08:10

jordanbtucker


drawnDivs = [];

like image 24
Mike Ruhlin Avatar answered Oct 03 '22 09:10

Mike Ruhlin