Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

298
Visualizações
why change() in constructor is not defined,it should be acessed through __proto__ link in p.__proto__?

why change() in constructor is not defined,it should be acessed through proto link in p.proto? why change() in constructor is not defined,it should be acessed through proto link in p.proto? why change() in constructor is not defined,it should be acessed through proto link in p.proto? why change() in constructor is not defined,it should be acessed through proto link in p.proto?

//the first change() is not defined ,why
class Person {
  constructor() {
    console.log(this)
    console.log(this.__proto__)
    // change()//output:is not define
  }
  
  change() {
    console.log(this)
  }
}

var p = new Person()
Object.prototype.change = function() {
  console.log(' change in prototype')
}
change() //output:change in prototype

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

Try calling it with this keyword.

    //the first change() is not defined ,why
class Person
   {
       constructor()
       {
           console.log(this)
           console.log(this.__proto__)
           this.change()//output:is not define
       }
       change()
       {
           console.log(this)
       }

   }
 
    var p =new Person()
    Object.prototype.change=function()
    {
        console.log(' change in prototype')
    }
    change()//output:change in prototype

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda