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

231
Views
How to get 'class' name like Chrome's dev console?

Below is a piece of code evaluated in Chrome's console. A function constructor is created anonymously and used to construct an object. Chrome happily prints the real constructor's name 'Foo'. But, I can't find a way to get it using standard JS. Where's the magic?

> var exports = {}
undefined
> (function(){var Foo = function() {}; Foo.prototype = "";  exports.bar = Foo;})()
undefined
> obj = new exports.bar();
Foo {}
> obj.constructor.name
'Object'
> obj.__proto__
{constructor: ƒ, __defineGetter__: ƒ, __defineSetter__: ƒ, hasOwnProperty: ƒ, __lookupGetter__: ƒ, …}
> obj.__proto__.name
undefined
> obj
Foo {}
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

To get Foo you can exports.bar.name

if (obj.__proto__.isPrototypeOf(exports.bar)) {
  console.log(exports.bar.name);
}
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!