Anyone explain me prototype and prototype chain and how it's work with constructor function?

please explain me this code🥺?

        function Poto(name,id,lastName){
            this.name_ = name;
            this.id_ = id;
            this.lastName = lastName;

        Poto.prototype.calcu_age = function(){
        } = "clash of clane"; 
        let newobj1 = new Poto("ultra",234,"lord");
        let newobj2 = new Poto("prince",4234,"sharma");
        let newobj3 = new Poto("eon",999,"lightning");

Just remember,whenever a constructor function is created ,it has an additional _proto property which is an object and has a property which points to constructor function itself.
Now when we use Person.prototype ,you are pointing to that _proto property.
In your case when you are stating


Just remember you are creating a new property on _proto object.

Now when you create a new object of Photo,you have access to _proto property of constructor function and hence property defined within the same.In your case calcu_age method and game property and can be used inside objects created with Poto function.

This whole concept is Prototypal inheritance.

Let me know,if you caught something or you need some more clarification.

1 Like

Can you explain me prototype chain and how it’s work and “Object” object and it’s use?