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

149
Vistas
Where are the methods stored in class declaration in javascript?

I want to know, in javascript when using the class keyword where are the prototype methods stored? For instance in the below code I have declared a Person class containing a method getInfo, When I try to do Person.prototype it outputs an empty object. But I've also read that classes are just syntactic sugar for constructor functions. But now I guess there's still some distinction between them, So can someone please explain what is it?

class Person {

    constructor(firstName, lastName) {
        this.firstName = firstName;
        this.lastName = lastName;
    }

    getInfo() {
        console.log(`First Name: ${this.firstName} \nLast Name: ${this.lastName}`);
    }
}

console.log(Person.prototype);

As far as I know if the same had to done using a Constructor function, Then it would be done something like the below code snippet.

function Person(firstName, lastName) {
  this.firstName = firstName;
  this.lastName = lastName;
}

Person.prototype.getInfo = function() {
  console.log(`First Name: ${this.firstName} \n ${this.lastName}`);
}

console.log(Person.prototype);

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