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

163
Vistas
What is the difference between creating object with NEW keyword using constructor and plain object regarding arrow functions methods?

I have a Function constructor A

function A(){
   this.number = 10;
   this.show = () => console.log(this.number)
}

So, I'm creating an object with this constructor

let a = new A();
//a={
//   number: 10, 
//   show: () => console.log(this.number)
//}

And plain object b

let b = {
   number: 20,
   show: () => console.log(this.number)
}

As result, I can say objects a and b syntactically equal a == b, but why

a.show() // gives 10
b.show() // undefined

I understand that for b, 'this' is a global object, that is why it is undefined in this case, but why there is different behavior for a?

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