Question PRG-JS-0072
HardWhat is the output of this program?
function Person(n) { this.n = n; }
Person.prototype.hi = function () { return "hi " + this.n; };
const a = new Person("x");
const b = Object.create(a);
b.n = "y";
console.log(a.hi(), b.hi(), Object.getPrototypeOf(b) === a, b.hasOwnProperty("hi"));
- A.
hi x hi y false false
- B.
hi x hi y true false
- C.
Sign up free to see the answer and a step-by-step explanation.