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

136
Vistas
Referencing a javascript object from within its declaration

Why is it possible to reference an object from within the object directly? For example:

var object = {
    prop1 : "Prop 1",
    prop2 : "Prop 2",
    func : _ => console.log(object)
}

object.func();

//output {prop1: 'Prop 1', prop2: 'Prop 2', func: ƒ}

Similarly I could do:

var object = {
    prop1 : "Prop 1",
    prop2 : "Prop 2",
    func : function() { console.log(this) }
}

object.func();

This will result in the same output as above. I am mainly trying to understand why it is legal to reference the variable name object from inside its declaration.

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

Attempts to access variables inside functions are not resolved until the function is called … which will be after the object is created.

about 4 years ago · Juan Pablo Isaza Denunciar
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