非常常用的一段代码
1 //数组移除指定对象或下标i 2 Array.prototype.remove = function (obj) { 3 for (var i = 0; i < this.length; i++) { 4 var temp = this[i]; 5 if (!isNaN(obj)) { 6 temp = i; 7 } 8 if (temp == obj) { 9 for (var j = i; j < this.length; j++) { 10 this[j] = this[j + 1]; 11 } 12 this.length = this.length - 1; 13 } 14 } 15 }
时间: 2025-01-02 03:45:50