js删除数组中的指定元素的方法为:
Array.prototype.remove = function(val) {
var index = this.indexOf(val);
if (index > -1) {
this.splice(index, 1);
}
}
调用方式为
var element = "xx"
arr.remove(element)
即可从数组中删除指定元素。
微信扫一扫
js删除数组中的指定元素的方法为:
Array.prototype.remove = function(val) {
var index = this.indexOf(val);
if (index > -1) {
this.splice(index, 1);
}
}
调用方式为
var element = "xx"
arr.remove(element)
即可从数组中删除指定元素。
相关推荐