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

180
Views
Constructor of a function declaration

Why does the following hold:

let F = function () {};
let f = new F();
console.log(f.__proto__.constructor === F, f.constructor === F);
// true

But the following does not:

let F = function () {};
console.log(F.prototype.constructor === F, F.constructor === F);
// true false

What then would be the constructor of a function declaration?

about 4 years ago · Santiago Trujillo
2 answers
Answer question

0

The .constructor property is an object is what you can call new on to create another such object.

That is, someF.constructor points to F, and you can use new F() to create someOtherF.

So, if F itself is what you want to make a similar type of object - what can you call to construct a function? Function.

let F = function () {};
console.log(F.constructor === Function);

In other words - you could use new Function to create something similar to F - a function that can create instances when new is called on it.

(That said, this would be extremely unusual - 99% of the time, functions should not be dynamic - there's no good reason to use new Function)

about 4 years ago · Santiago Trujillo Report

0

The constructor of a function is Function.

let F = function () {};
console.log(F.__proto__.constructor === Function, F.constructor === Function);
// true false

about 4 years ago · Santiago Trujillo 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!