splice从数组中删除指定定数据

/*
从数组中删除指定定数据
var somearray = ["mon", "tue", "wed", "thur"]
somearray.removeByValue("tue");
//somearray will now have "mon", "wed", "thur"
*/
Array.prototype.removeByValue = function (val) {
for (var i = 0; i < this.length; i++) {
if (this[i] == val) {
this.splice(i, 1);
break;
}
}
}

原文地址:https://www.cnblogs.com/wu-peng/p/5514732.html