Sunday, 21 May 2017

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




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.



Answer



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


No comments:

Post a Comment

c++ - Does curly brackets matter for empty constructor?

Those brackets declare an empty, inline constructor. In that case, with them, the constructor does exist, it merely does nothing more than t...