Array.prototype.remove = function(dx) {
if(isNaN(dx) || dx > this.length) {
return false;
}
for(var i = 0, n = 0; i < this.length; i++) {
if(this[i] != this[dx]) {
this[n++] = this[i]
}
}
this.length -= 1
}
var a = [1, 2, 3, 4, 5]; //目标數組
a.remove(4); //删除目标數組的下标
console.log(a)