SOURCE

Function.prototype.method = function(name, func) {
    if (!this.prototype[name]) {
        this.prototype[name] = func;
    }
    return this;
};

Function.method('mybind', function(that) {
    method = this;
    slice = Array.prototype.slice;
    args = slice.apply(arguments, [1]);
    console.log(args.concat(slice.apply(arguments, [0])));
    return function() {
        return method.apply(that, args.concat(slice.apply(arguments, [0])));
    };
});

var getValue = function() {
    return this.value;
}

var x = getValue.mybind({value: "hello"}, "hhargs2", 'hhhhh');

console.log(x());
console 命令行工具 X clear

                    
>
console