Class的基本语法章节书写错误
idigan opened this issue · comments
idigan commented
class A {
#foo = 0;
static test(obj) {
console.log(#foo in obj);
}
}
const a = new A();
const o1 = Object.create(a);
A.test(o1) // false
A.test(o1.__proto__) // true
const o2 = {};
Object.setPrototypeOf(o2, A);
A.test(o2) // false
A.test(o2.__proto__) // true
语句Object.setPrototypeOf(o2, A)
中的字母A应该为 a
这样A.test(o2.__proto__)
结果才为 true
Ruan YiFeng commented
谢谢指出,已经更正。