通过使用prototype在继承内建类特性的同时加入新方法

Array.prototype.removeElement = function (item:*):void {

  var index:int = this.indexOf(item);  

  if(index>-1){  

    this.splice(index,1);  

  }

}

var arr:Array = [1,2,3];

arr.removeElement(1);

trace(arr);//2,3

相关文章:

  • 2021-11-12
  • 2022-12-23
  • 2021-06-26
  • 2021-08-04
  • 2022-02-14
  • 2021-09-27
猜你喜欢
  • 2022-12-23
  • 2021-08-24
  • 2021-05-23
  • 2021-06-16
  • 2021-06-05
  • 2022-12-23
  • 2022-02-12
相关资源
相似解决方案