首页 > 编程知识 正文

js数组添加删除,js删除数组数据

时间:2023-05-03 21:11:24 阅读:198557 作者:4281

//新建数组var ids =new Array();//向数组中添加数据ids.push(1);//删除下标为i的数组元素ids.remove(i);//自定义删除函数: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}

 

转载于:https://www.cnblogs.com/yysbolg/p/8806543.html

版权声明:该文观点仅代表作者本人。处理文章:请发送邮件至 三1五14八八95#扣扣.com 举报,一经查实,本站将立刻删除。