var foo = {
value :1
}
function bar(name){
console.log('......')
console.log(name)
this.b = '22';
console.log(this.value)
}
var value =3
bar.prototype.a = 'wgf'
Function.prototype.bind2 = function(context){
if (typeof this !== "function") {
throw new Error("Function.prototype.bind - what is trying to be bound is not callable");
}
var self = this;
var fnull = function(){}
var args = Array.prototype.slice.call(arguments,1)
var fn = function(){
var argsBind = Array.prototype.slice.call(arguments)
self.apply(this instanceof self?this :context,args.concat(argsBind))
}
fnull.prototype = this.prototype;
fn.prototype = new fnull();
return fn
}
var obj = bar.bind2(a);
console