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

147
Views
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
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!