-
-
Notifications
You must be signed in to change notification settings - Fork 33.2k
Closed
Labels
confirmed-bugIssues with confirmed bugs.Issues with confirmed bugs.utilIssues and PRs related to the built-in util module.Issues and PRs related to the built-in util module.
Description
Consider following code
class A {
getA() { return 0; }
constructor() {}
}
class B extends A {
getB() { return 0; }
constructor() { super(); }
}
console.log((new A()));
console.log((new A()).__proto__);
console.log((new A()).__proto__ instanceof A);
console.log((new A()).__proto__ instanceof Object);
console.log((new B()));
console.log((new B()).__proto__);
console.log((new B()).__proto__ instanceof B);
console.log((new B()).__proto__ instanceof A);
Node 14 produces:
A {}
A {}
false
true
B {}
B {}
false
true
This is wrong since (new B()).__proto__
is an instance of A
. I guess the confusing part is that (new B()).__proto__.constructor
is class B
(which is because of https://tc39.es/ecma262/#sec-makeconstructor)
For reference, Chrome DevTools produces:
A {}
{constructor: ƒ, getA: ƒ}
false
true
B {}
A {constructor: ƒ, getB: ƒ}
false
true
addaleax and Wokoro
Metadata
Metadata
Assignees
Labels
confirmed-bugIssues with confirmed bugs.Issues with confirmed bugs.utilIssues and PRs related to the built-in util module.Issues and PRs related to the built-in util module.