Home  >  Article  >  Web Front-end  >  Mozilla expression __noSuchMethod___javascript trick

Mozilla expression __noSuchMethod___javascript trick

WBOY
WBOYOriginal
2016-05-16 18:54:32941browse

Mozilla expression __noSuchMethod___javascript trick

Copy code The code is as follows:

//only Can run under 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");

When we execute an undefined method in the test object, the __noSuchMethod__ method will be automatically executed, so that we can use it to do some fault tolerance and monitoring work.
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn