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

303
Views
TypeError no detectado: no se puede establecer un campo privado: el objeto no es la clase correcta

Tengo una clase llamada Timer:

 class Timer { #tick() { console.error('Error usage of interface Timer explicitly deleted'); } startTimer() { console.error('Error usage of interface Timer explicitly deleted'); } }

Y tengo una clase llamada CyclingTimer que se deriva de Timer:

 class CyclingTimer extends Timer { #maximumTime #timeBetweenTicks #currentTime #onTick constructor(maximumTime, timeBetweenTicks) { super(); this.#maximumTime = maximumTime; this.#timeBetweenTicks = timeBetweenTicks; this.#currentTime = 1; } #validateBoundaries() { if(this.#currentTime > this.#maximumTime) this.#currentTime = 1; else if(this.#currentTime < 1) this.#currentTime = this.#maximumTime; } #tick() { //I console.log(this) here to debug and it printed the Window object as this. I don't know why this.#currentTime++; //Error Occures In This Line this.#validateBoundaries(); this.#onTick(); } startTimer() { //When I console.log(this) here it prints CyclingTimer as expected setInterval(this.#tick, this.#timeBetweenTicks); } setOnTickFunction(callbackFunction) { this.#onTick = callbackFunction; } }

No tengo idea de por qué sucede esto y estas son las únicas cosas que tengo. Cuando busqué sobre el error no encontré nada.

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Finalmente resolví el problema. El problema fue cuando al usar setInterval() 'tick()' perdí su 'esto' para resolver este problema, vinculo 'tick()' a mi objeto que pasar la función enlazada a setInterval()

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!