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

JS 删除数组中元素方法

时间:2017-11-01 16:31:49      阅读:184      评论:0      收藏:0      [点我收藏+]

标签:function   prot   his   type   dex   删除   prototype   func   nbsp   

Array.prototype.remove = function(val) {
var index = this.indexOf(val);
if(index > -1) {
this.splice(index, 1);
}
};

var arr = [‘1‘,‘2‘,‘3‘];

arr.remove("2")  ->  arr =  [‘1‘,‘3‘];

JS 删除数组中元素方法

标签:function   prot   his   type   dex   删除   prototype   func   nbsp   

原文地址:http://www.cnblogs.com/mrt-yyy/p/7766823.html

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