//自执行函数的调用三种 /* !function(){ alert(123) }(); (function(){ alert(345) }()) (function(){ Array.prototype.push.call(arguments,3); console.log(arguments)//输出 [1,2,3] })(1,2) */ var obj = { a:1, b:function(){ console.log(this); } } obj.fn = function(){ console.log(this);//===obj } obj.fn(); obj.b();//this==obj //var c = obj.b();//this==obj //c();//this==window; Function.prototype.bind = function(context){ var self = this; console.log('测试bind') console.log(this); // function(){var c = 1} return function(){ return self.apply(context,arguments) } } var o = { name:'my name id huhu' } var func = function(){ alert(this.name) }.bind(o); console.log(func) //function(){return self.apply(context,argument)} func();