javascript 加入 移除陣列元素

摘要: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); }