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

142
Views
Función anidada que pierde este alcance

Tengo un script js que funciona bien por sí solo, sin embargo, cuando intento mover mi código para reaccionar, la función anidada/referenciada pierde 'esto' y hace referencia a la ventana en su lugar. Pseudocódigo a continuación. ¿Alguna idea de qué causa esto? Me imagino que está relacionado con el paquete web o algo que está haciendo reactjs.

 lib.AnMovieClip = function() { this.testVariable = true; this.gotoAndPlay = function(){ // 'this' works here perfectly fine this.otherFunction(); } this.otherFunction(){ // returns undefined, as 'this' is now the window object console.log(this.testVariable); } }
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Terminé encontrando que el valor no se estaba asignando correctamente. this.testVariable se estaba sobrescribiendo.

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!