Mozilla表达式__noSuchMethod___javascript技巧
来源:动视网
责编:小采
时间:2020-11-27 20:42:28
Mozilla表达式__noSuchMethod___javascript技巧
Mozilla表达式__noSuchMethod___javascript技巧: 代码如下://只能在firefox下运行 var test = { name: puterjam, __noSuchMethod__: function(name, args){ alert([Your call an error function [,name,]. Arguments list: [,args,]].join(
导读Mozilla表达式__noSuchMethod___javascript技巧: 代码如下://只能在firefox下运行 var test = { name: puterjam, __noSuchMethod__: function(name, args){ alert([Your call an error function [,name,]. Arguments list: [,args,]].join(


代码如下:
//只能在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__方法,这样我们可以利用他来作一些容错和监控的工作。
Mozilla表达式__noSuchMethod___javascript技巧
Mozilla表达式__noSuchMethod___javascript技巧: 代码如下://只能在firefox下运行 var test = { name: puterjam, __noSuchMethod__: function(name, args){ alert([Your call an error function [,name,]. Arguments list: [,args,]].join(