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

300
Visualizações
Why are there different ways to create a function in JavaScript? (Hoisting?)

I know that there are 3 ways of creating functions

Function Declaration. Function Expression. Arrow Function.

function foo(){
console.log("boo");
{

and

var foo = function(){
console.log("boo");
}

I know that the first one is hoisted so that even if we call it before the function it will work. For the second one because it is an assigned variable hoisting will not work.

My question why is there such a requirement? I just started learning JS and it does not make sense to me yet to set the difference between those two.

Also how about Arrow Function? Why do we need it as well?

Thank you

Edit1: I found my answer for the question of Arrow Functions which seems too advanced for me. I will review it as I go.

When should I use arrow functions in ECMAScript 6?

I am still not clear about the difference between Function Declaration and Function expression.

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