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

310
Visualizações
Destroy an instance of class in javascript

I tried to pass to null an instance of class but in vain. Here avatar2 is not delete, why ? console log

class Avatar{
  constructor(name, weapon = "knife", pv = 100){
    this.name = name;
    this.weapon = weapon;
    this.pv = pv;
  }
  attaqueDefault(target){
    if (target.hasOwnProperty('pv'))
      target.pv -= 20;
  }
  attaqueCombine(target){
    if (target.hasOwnProperty('pv'))
      target.pv -= 35;
  }
  destroy(target){
    target = undefined;
  }
}

var avatar = new Avatar("tchod");
var avatar2 = new Avatar("tchod2", ".44");

avatar.destroy(avatar2);
about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

try changing avatar to Avatar

Avatar.destroy(avatar2);

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