每日一题 2020-11-13

下面这段JS程序的执行结果是:

var user = {
   count : 1,
  getCount: function(){
    return this.count;
  }
}
var func = user.getCount
console.log(func())

答案: undefined

解析:
this 指向 window

var func = user.getCount
var func = function(){
    return this.count;
}

window.count = undefined

posted @ 2020-11-19 15:01  pandajs163  阅读(139)  评论(0)    收藏  举报