Prototype-based Inheritance in JavaScript with Constructors using Object.create()

const obj = {}; // Create an empty object named 'obj' Object.preventExtensions(obj); // Prevent any extensions to the 'obj' object (i.e., disallow adding new properties) obj.o = 3; // Attempt to add a property 'o' to the 'obj' object, but this operation will be ignored due to preventExtensions console.log( obj.hasOwnProperty("o") // Log whether the 'obj' object has the property "o" directly defined on it );

Output: