delete 删除当前对象的属性或方法

function Person(){

}

Person.prototype.eat=function(){
       alert('person eat');
}

var gg=new Person();
gg.eat=function(){ 
      alert('gg eat');
}
delete gg.eat;
gg.eat(); //alert person eat

总结:

             delete 只删除当前对象中的值,而不会删除prototype中的值。

    如果要删除prototype中的值,使用delete Person.prorotype.eat

相关文章:

  • 2021-06-14
  • 2021-10-18
  • 2022-12-23
  • 2021-10-12
  • 2022-12-23
  • 2022-12-23
  • 2021-11-17
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2021-11-15
  • 2022-12-23
  • 2021-10-06
  • 2021-11-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案