Mozilla 表达式 __noSuchMethod__





复制代码 代码如下:

//只能在firefox下运行
var test = {
name: "puterjam",
__noSuchMethod__: function(name, args){
alert(["Your call an error function [",name,"]. Arguments list: [",args,"]"].join(""));
}
}
test.hello();
test.helloWorld("china","shenzhen");

当我们执行了test对象里的某一个没有定义的方法,就会自动执行__noSuchMethod__方法,这样我们可以利用他来作一些容错和监控的工作。
« 
» 
快速导航

Copyright © 2016 phpStudy | 豫ICP备2021030365号-3