Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

183
Visualizações
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 Respostas
Responde à pergunta

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 Relatório

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda