请看一下这段代码
var arr = [1, 2];
var obj = Object.create(arr); // should create a new object with arr as its prototype
console.log(obj) // logs [1, 2]
console.log(Object.getPrototypeOf(obj)) // logs [1, 2]
obj
[[prototype]]
与arr
绑定的空对象不应该是obj
吗?与预期相反,[1, 2]
被记录为数组[[prototype]]
:
将数组设置为对象的itemgetter
是什么意思?