javascript bind

zyip發表於2015-04-23

 

 

var bar = {
  var1:'var1',
  var2:'var2',
  fun1:function(){
    var arg0=arguments[0];
    arg0=arg0 || "";
    console.log( arg0 + this.var2);
  }
};

bar.fun1('fun1 ');





var bar2={
    var1:'var111',
    var2:'var222'
};

var fun1=bar.fun1.bind(bar2,'fun2 ');
fun1();

 

相關文章