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

139
Views
Prototype of class's instances?

I'm trying to understand why the following code works the way it does.

I think it's contradictory that logging killerRabbit.prototype gives undefined while at the same time it seems to be equal to Rabbit.prototype.

Does it has an associated prototype but no actual prototype as a property?.

In that case, how do I access those prototypes properties?

class Rabbit {
  constructor(type) {
    this.type = type;
  }
  speak(line) {
    console.log(`The ${this.type} rabbit says '${line}'`);
  }
}
let killerRabbit = new Rabbit("killer");
console.log(Object.getPrototypeOf(killerRabbit)==Rabbit.prototype);//true
console.log(killerRabbit.prototype);//undefined
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

If you want to access the prototype property on an instance, try this:

console.log(killerRabbit.__proto__);

And this property point to the prototype property of the based class.

console.log(killerRabbit.__proto__ === Rabbit.prototype); // true
about 4 years ago · Juan Pablo Isaza Report
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!