我在MDN上遇到了这个例子,它不像描述的那样工作:
function makePerson(first, last) {
return {
first: first,
last: last,
fullName: function() {
return this.first + ' ' + this.last;
},
fullNameReversed: function() {
return this.last + ', ' + this.first;
}
}
}
Example Call:
> s = makePerson("Simon", "Willison")
> s.fullName()
Simon Willison
> s.fullNameReversed()
Willison, Simon
这篇文章写于 2006 年,在 IE10 和 Chrome 26 中,它只显示了 fullName 和 fullNameReversed 函数的文字代码。此功能是否不再适用于现代浏览器?