Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

109
Vistas
Why arrow function has different parent-scope in this two scenarios?

I know arrow functions binds the parent-scope to 'this' keyword, but is it not the same parent calling the arrow function in this two scenarios?

Both are being called by a console.log inside a "fn" function. Why do I receive different context output?

Expected:

function wuwu() {
    this.a = () => this

    this.fn = function () {
        console.log(this) // wuwu {a: ƒ, fn: ƒ}
        console.log(this.a()) // wuwu {a: ƒ, fn: ƒ}
    }
}
const wewe = new wuwu()
wewe.fn()

Not expected:

let wuwu = {
  a: () => this,
    
  fn: function() {
      let fn2 = () => {
          console.log(this) // {a: ƒ, fn: ƒ}
          console.log(this.a()) // Window {0: Window, 1: Window, window: Window, self: Window, document: document, name: '', location: Location, …}
      }
      fn2()
 }
}
wuwu.fn()
about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda