我有这段代码:
const employee = {
name: 'Jen Baker',
getName: function() {
return this.name;
}
};
const getEmployeeName = employee.getName;
console.log(getEmployeeName()); // returns '' (empty string)
为什么getEmployeeName()
会返回一个空字符串?不应该是undefined
,因为它在员工对象中失去了对this.name
的引用?空字符串来自哪里?