Is JavaScript's array.clear() not a function?
This question already has an answer here:
Nope, it's not. But drawnDivs.length = 0
should work.
drawnDivs = [];
It was answered in Stack Overflow question How do I empty an array in JavaScript?.
Two examples from the answer:
var A = ['some', 'values', 'here'];
//Method 1
//(This was my original answer to the question)
A = [];
// Method 2 (as suggested by Matthew Crumley)
A.length = 0
And here is a nice write up on these two methods by Dr. Axel Rauschmayer.
链接地址: http://www.djcxy.com/p/23940.html上一篇: 如何从数组中删除元素?