Do you know what will be the output of this code?
JavaScript
const parent = { a: 1 };
const child = Object.create(parent);
console.log("a" in child, child.hasOwnProperty("a"));
Show answer and explanation
The answer is true false.
child inherits a from its prototype. in follows the prototype chain, while hasOwnProperty (or the newer Object.hasOwn) only looks at the object’s own properties.