Home > Web Front-end > JS Tutorial > Mozilla expression __noSuchMethod___javascript trick

Mozilla expression __noSuchMethod___javascript trick

WBOY
Release: 2016-05-16 18:54:32
Original
962 people have browsed it

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.
Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template