标签:
<script type="text/javascript"> //删除元素值 Array.prototype.remove = function(element){ for (var i = 0,j=0; i < this.length; i++) { if(this[i]!=element){ this[j++]=this[i]; } } this.length-=1 } //删除元素下标 Array.prototype.removeIndex=function(dx) { if(isNaN(dx)||dx>this.length) { alert("删除对象下标越界"); return false; } for(var k=0,n=0;k<this.length;k++) { if(this[k]!=this[dx]) { this[n++]=this[k]; } } this.length-=1 } var arr =["Iphone","MI","SAMSUNG","VIVO","OPPO","HUAWEI","ZTE","SONY","Coolpad","GiONEE","MEIZU","nubia","Letv","TCL"]; arr.push("NOKIA"); arr.remove("Iphone");
arr.removeIndex(1); alert(arr.join(",")); </script>
标签:
原文地址:http://www.cnblogs.com/zhaojinhui/p/4981313.html