Is there a way to handle undefined functions being called in JavaScript?

后端 未结 2 1641
无人共我
无人共我 2021-02-15 03:23

If I have a function like the following:

function catchUndefinedFunctionCall( name, arguments )
{
    alert( name + \' is not defined\' );
}

an

2条回答
  •  感动是毒
    2021-02-15 03:26

    try {
     foo();
    }
    catch(e) {
       callUndefinedFunctionCatcher(e.arguments);
    }
    

    UPDATED

    passing e.arguments to your function will give you what you tried to pass originally.

提交回复
热议问题