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

后端 未结 2 1303
梦如初夏
梦如初夏 2021-02-15 03:20

If I have a function like the following:

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

an

2条回答
  •  栀梦
    栀梦 (楼主)
    2021-02-15 03:33

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

    UPDATED

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

提交回复
热议问题