本文介绍了有没有办法处理JavaScript中调用的未定义函数?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 29岁程序员,3月因学历无情被辞! 如果我有如下功能:function catchUndefinedFunctionCall( name, arguments ){ alert( name + ' is not defined' );}我做一些傻事像foo( 'bar' );when foo isn't defined, is there some way I can have my catch function called, with name being 'foo' and arguments being an array containing 'bar'?推荐答案还有Mozilla Javascript 1.5(非标准)There is in Mozilla Javascript 1.5 anyway (it's nonstandard).检查出来:var myObj = { foo: function () { alert('foo!'); } , __noSuchMethod__: function (id, args) { alert('Oh no! '+id+' is not here to take care of your parameter/s ('+args+')'); }}myObj.foo();myObj.bar('baz', 'bork'); // => Oh no! bar is not here to take care of your parameter/s (baz,bork)很酷。请访问 https://developer.mozilla.org/en/Core_JavaScript_1阅读更多信息。 5_Reference / Global_Objects / Object / NoSuchMethod 这篇关于有没有办法处理JavaScript中调用的未定义函数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云!
08-30 23:18