如果我有如下功能:
function catchUndefinedFunctionCall( name,arguments ) { alert( name + ' is not defined' ); }
而我做的事情很傻
foo( 'bar' );
解决方法
无论如何都有Mozilla Javascript 1.5(它是非标准的).
看一下这个:
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