当前位置:Gxlcms > JavaScript > Mozilla 表达式 __noSuchMethod__

Mozilla 表达式 __noSuchMethod__

时间:2021-07-01 10:21:17 帮助过:1人阅读




代码如下:
//只能在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__方法,这样我们可以利用他来作一些容错和监控的工作。

人气教程排行