📜  绑定的polyfill - Javascript代码示例

📅  最后修改于: 2022-03-11 15:01:06.980000             🧑  作者: Mango

代码示例2
Function.prototype.cbind = function (...outer_args) {
    let that = this,
        params = outer_args.slice(1),
        obj = outer_args[0];

    return function (...inner_args) {
        that.apply(obj, [...params, ...inner_args]);
    }
}