JS bind的实现

// 模拟原生JS中的bind, 将函数指针以值的形式传递,该函数必须在特定环境中执行
function bind(fn, context) {
    var args = Array.prototype.slice.call(arguments, 2);
    return function () {
        var innerArgs = Array.prototype.slice.call(arguments);
        var finalArgs = args.concat(innerArgs);
        return fn.apply(context, finalArgs);
    };
}
原文地址:https://www.cnblogs.com/shanchenba/p/5610902.html