为什么下面的printActions函数中的'this'关键字可以访问'actions'数组,但forEach循环内的匿名函数中的'this'关键字无法访问'first'name属性?< / p>
var person = {
first: "Steve",
actions: ['run', 'swim', 'bike'],
printActions: function () {
this.actions.forEach(function (action) {
var str = this.first + " likes to " + action;
console.log(str);
}); //end forEach
}//end printActions function
};// person object
person.printActions();