SOURCE

Function.prototype.bind = function(obj,arg) {
  var arg=Array.prototype.slice.call(arguments,1);
  var context = this;
  var bound = function(newArg) {
    arg = arg.concat(Array.prototype.slice.call(newArg));
    return context.apply(obj,arg);
  }
  var F = function() {};
  F.prototype = context.prototype;
  bound.prototype = new F();
  return bound;
}

var name = 'name';
var test ={
  name:"test"
}
function fn() {
  console.log(this.name);
}
console.log(fn());
console 命令行工具 X clear

                    
>
console