Open this example in the interactive library
Source code
const obj = Object.create({ inherited: 1 });
obj.own = 2;
console.log(Object.hasOwn(obj, "own"), Object.hasOwn(obj, "inherited"));
Sample output
true false

Check own properties. A self-contained example using the JavaScript runtime.
Open this example in the interactive library
const obj = Object.create({ inherited: 1 });
obj.own = 2;
console.log(Object.hasOwn(obj, "own"), Object.hasOwn(obj, "inherited"));
true false