作用域问题

153 阅读1分钟
1.函数内的this指向window,但是如果这个函数是某个引用指向的,那么就是这个引用
var a = {
    b: function() {
      console.log(this.c, '----------------')
      var func = function() {
        console.log(this.c);
      }
      func();
    },
    c: 'hello'
}
a.b(); 
var d = a.b;
d()
hello
undefined // 
undefined // 属性和变量的区别