经典指数          
原因
3125
浏览数
0
收藏数
 

var myObject = {
    foo: "bar",
    func: function() {
        var self = this;
        console.log(this.foo);   
        console.log(self.foo);   
        (function() {
            console.log(this.foo);   
            console.log(self.foo);   
        }());
    }
};
myObject.func();
程序的输出是什么?
  • bar bar bar bar
  • bar bar bar undefined
  • bar bar undefined bar
  • undefined bar undefined bar

     举报   纠错  
 
切换
1 个答案

func : self == this  is true

(function(){});  self != this..

 
切换
撰写答案