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

// Create an empty object as the prototype const prototype1 = {}; // Create an object with prototype prototype1 const object1 = Object.create(prototype1); // Create an empty object as the prototype const prototype2 = {}; // Create an object with prototype prototype2 const object2 = Object.create(prototype2); // Check if the prototype of object1 is prototype1 console.log(Object.getPrototypeOf(object1) === prototype1); // Check if the prototype of object1 is prototype2 console.log(Object.getPrototypeOf(object1) === prototype2);

Output: