javascript bind

 

 

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();

 

posted @ 2015-04-23 16:39  zyip  阅读(122)  评论(0编辑  收藏  举报