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

javascript 加入 移除数组元素

时间:2019-09-12 09:29:28      阅读:94      评论:0      收藏:0      [点我收藏+]

标签:move   array   ==   cti   www   ems   javascrip   func   var   

摘要:javascript 加入 移除数组元素


记录一下

???????????????? //移除数组
??????????????Array.prototype.removeItems = function(itemsToRemove) ...{
??????????????????var j = 0;
??????????????????while (j < this.length) ...{
??????????????????????if (this[j] == itemsToRemove) ...{
??????????????????????????this.splice(j, 1);
??????????????????????} else ...{
??????????????????????????j++;
??????????????????????}
??????????????????}

??????????????}
??????????????
??????????????//加入数组
??????????????Array.prototype.addItems = function(itemsToAdd) ...{ this.push(itemsToAdd); }

原文:大专栏  javascript 加入 移除数组元素


javascript 加入 移除数组元素

标签:move   array   ==   cti   www   ems   javascrip   func   var   

原文地址:https://www.cnblogs.com/petewell/p/11509955.html

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