- /*
- * 方法:Array.removeAt(Index)
- * 功能:删除数组元素.
- * 参数:Index删除元素的下标.
- * 返回:在原数组上修改数组
- */
- Array.prototype.removeAt = function(Index) {
- if (isNaN(Index) || Index > this.length) {
- return false;
- }
- for (var i = 0, n = 0; i < this.length; i++) {
- if (this[i] != this[Index]) {
- this[n++] = this[i]
- }
- }
- this.length -= 1
- }
- /*
- * 方法:Array.remove(obj)
- * 功能:删除数组元素.
- * 参数:要删除的对象.
- * 返回:在原数组上修改数组
- */
- Array.prototype.remove = function(obj) {
- if (null == obj) {
- return;
- }
- for (var i = 0, n = 0; i < this.length; i++) {
- if (this[i] != obj) {
- this[n++] = this[i];
- }
- }
- this.length -= 1
- }