bind

var jane = {
    hoho: 'Jane',
    describe: function() {
        return 'Person named ' + this.hoho;
    }
};
var fun = jane.describe; // this 是全局window
console.log(fun());
var func2 = jane.describe.bind(jane); //this是jane 即作用域绑定
console.log(func2());

  

posted @ 2015-03-11 18:09  lcw5945  阅读(93)  评论(0编辑  收藏  举报