Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

308
Views
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 answers
Answer question

0

try changing avatar to Avatar

Avatar.destroy(avatar2);

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!