首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > JavaScript >

javascript的有关问题

2012-04-07 
javascript的问题functionb(){this.cfunction (){}}b.prototype.afuncion(){}如果我想删除不是在构造函

javascript的问题
function b(){
  this.c=function (){

  }
}
b.prototype.a=funcion(){}

如果我想删除不是在构造函数内定义的方法(比如这里我要删除a),该怎么写?

[解决办法]
var s = new b();
delete s.a;
[解决办法]
简单得很:
b.prototype.a=undefind;

[解决办法]
function b(){
this.c=function (){

}
}
b.prototype.a=function(){}

var s = new b();

for(var k in s){
if( !s.hasOwnProperty(k) && s[k].constructor == Function )delete s[k]
}
[解决办法]

探讨

function b(){
this.c=function (){

}
}
b.prototype.a=function(){}

var s = new b();

for(var k in s){
if( !s.hasOwnProperty(k) && s[k].constructor == Function )delete s[k]
}

热点排行