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

134
Views
Listing constructor properties vs prototype properties

Is the following the correct way to retrieve properties that are defined in the prototype and those defined in the constructor?

function greet(name) {
    this.name = name;
}

greet.prototype.new = "New"
greet.prototype.print = function() {console.log('Hi!', this.name)};
let o = Object.create(greet.prototype);
o.constructor("Bob")

console.log('Prototype props:', Object.keys(Object.getPrototypeOf(o)));  
console.log('Constructor props:', Object.getOwnPropertyNames(o));         

Additionally, is there a more straightforward way to grab the prototype properties than doing Object.keys(Object.getPrototypeOf(o)) ?

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!