Skip to main content
Improve code formatting
Source Link
Samuel Caillerie
  • 8.3k
  • 2
  • 29
  • 34
    function Test()
    {
        this.name = 'test name';
    
    }
    

console.log(Test.prototype.constructor.prototype.constructor);

I can't understand why is this a infinite chain of constructor constructor - prototypeprototype?

I mean which are the purpose of this chain and why there is no end, the prototype has a constructor and the constructor has a prototype, its a loop-chain, and the constructor everytime is the same, can't imagine...

    function Test()
    {
        this.name = 'test name';
    
    }
    

console.log(Test.prototype.constructor.prototype.constructor);

I can't understand why is this a infinite chain of constructor - prototype?

I mean which are the purpose of this chain and why there is no end, the prototype has a constructor and the constructor has a prototype, its a loop-chain, and the constructor everytime is the same, can't imagine...

function Test()
{
    this.name = 'test name';
}
    

console.log(Test.prototype.constructor.prototype.constructor);

I can't understand why is this a infinite chain of constructor - prototype?

I mean which are the purpose of this chain and why there is no end, the prototype has a constructor and the constructor has a prototype, its a loop-chain, and the constructor everytime is the same, can't imagine...

Source Link
Hello
  • 2.3k
  • 4
  • 24
  • 30

javascript prototype constructor confusion

    function Test()
    {
        this.name = 'test name';
    
    }
    

console.log(Test.prototype.constructor.prototype.constructor);

I can't understand why is this a infinite chain of constructor - prototype?

I mean which are the purpose of this chain and why there is no end, the prototype has a constructor and the constructor has a prototype, its a loop-chain, and the constructor everytime is the same, can't imagine...