Javascript super()是否映射到引擎盖下的_proto__?
我知道ES6中的类实际上是语法糖。super()调用真的只是调用proto吗?(它映射到[[prototype]]对象了吗?它比这个稍微多一些。它还记得方法的定义位置Javascript super()是否映射到引擎盖下的_proto__?,javascript,es6-class,Javascript,Es6 Class,我知道ES6中的类实际上是语法糖。super()调用真的只是调用proto吗?(它映射到[[prototype]]对象了吗?它比这个稍微多一些。它还记得方法的定义位置 const example = { method() { return super.method(); } } 语法上的糖是什么 const example = { method() { return Object.getPrototypeOf(example).metho
const example = {
method() {
return super.method();
}
}
语法上的糖是什么
const example = {
method() {
return Object.getPrototypeOf(example).method.call(this);
}
}
class Example {
method() {
return Object.getPrototypeOf(Example.prototype).method.call(this);
}
}
及
语法上的糖是什么
const example = {
method() {
return Object.getPrototypeOf(example).method.call(this);
}
}
class Example {
method() {
return Object.getPrototypeOf(Example.prototype).method.call(this);
}
}
对于构造函数中的super()
它是否映射到[[prototype]]对象
对。不是调用函数的对象的[[prototype]](this
),而是定义函数的对象的[[prototype]]。否,它没有调用\uuuuuuuuu
。这是一个不推荐使用的getter/setter,任何东西都不应该使用它。