首页 > 编程语言 > 详细

js数组移除指定对象或下标i

时间:2017-01-20 17:19:40      阅读:465      评论:0      收藏:0      [点我收藏+]

非常常用的一段代码

 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 }

 

js数组移除指定对象或下标i

原文:http://www.cnblogs.com/yijinc/p/6323187.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!