uncurrying (this泛化 强调方法的调用,不注重是哪个对象的方法)

110 阅读1分钟
Function.prototype.uncurrying = function () {
    var self = this;
    console.log(this)
    return function () {
        var obj = Array.prototype.shift.call(arguments);
        return self.apply(obj, arguments);
    };
};
var push = Array.prototype.push.uncurrying();

(function () {
    push(arguments, 4);
    console.log(arguments); // 输出:[1, 2, 3, 4]
})(1, 2, 3);