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

function fruits() { // Defines a constructor function named "fruits" this.name = 'franco'; // Creates a property "name" and assigns it the value 'franco' within the "fruits" constructor } function fun() { // Defines another constructor function named "fun" fruits.call(this); // Calls the "fruits" constructor within the context of the current object (this), effectively setting its properties } fun.prototype = Object.create(fruits.prototype); // Creates a new object that inherits from the prototype of "fruits" and sets it as the prototype of "fun" const app = new fun(); // Creates a new instance of the "fun" constructor and assigns it to the variable "app" console.log(app.name); // Outputs the value of the "name" property of the "app" object, which is 'franco'

Output: