码迷,mamicode.com
首页 > 编程语言 > 详细

js 删除数组元素

时间:2016-03-08 10:55:05      阅读:195      评论:0      收藏:0      [点我收藏+]

标签:js 删除数组元素

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
     }

js 删除数组元素

标签:js 删除数组元素

原文地址:http://cbg23.blog.51cto.com/7201812/1748646

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!