在一些javascript实现中有一个noSuchMethod功能(Rhino,SpiderMonkey)
proxy = {
__noSuchMethod__: function(methodName, args){
return "The " + methodName + " method isn't implemented yet. HINT: I accept cash and beer bribes" ;
},
realMethod: function(){
return "implemented" ;
}
}
js> proxy.realMethod()
implemented
js> proxy.newIPod()
The newIPod method isn't implemented yet. HINT: I accept cash and beer bribes
js>
Run Code Online (Sandbox Code Playgroud)
我想知道,有没有办法为房产做类似的事情?我想编写可以在属性和方法上分派的代理类.
javascript ×1