Using Function.prototype.bind with an array of arguments?

后端 未结 10 1879
春和景丽
春和景丽 2020-12-08 01:57

How can I call Function.prototype.bind with an array of arguments, as opposed to hardcoded arguments? (Not using ECMA6, so no spread operator).

I\'m trying to put a

10条回答
  •  我在风中等你
    2020-12-08 02:41

    Felix's answer didn't work for me because the arguments object isn't really an array (as Otts pointed out). The solution for me was to simply switch bind and apply:

    bound = db.find.apply.bind(db.find, null, arguments);
    

提交回复
热议问题