Javascript add extra argument

后端 未结 11 1050
暖寄归人
暖寄归人 2021-02-06 22:02

Lets take a look at this code:

var mainFunction = function() {
  altFunction.apply(null, arguments);
}

The arguments that are passed to \"mainF

11条回答
  •  花落未央
    2021-02-06 22:17

    arguments is not a pure array. You need to make a normal array out of it:

    var mainArguments = Array.prototype.slice.call(arguments);
    mainArguments.push("extra data");
    

提交回复
热议问题