JS 删除数组中元素方法

Array.prototype.remove = function(val) {
var index = this.indexOf(val);
if(index > -1) {
this.splice(index, 1);
}
};

var arr = ['1','2','3'];

arr.remove("2")  ->  arr =  ['1','3'];

posted @ 2017-11-01 15:43  mrt_yy  阅读(216)  评论(0编辑  收藏  举报