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

185
Visualizações
I don't know the difference

I've just started learning about function. and here is what gives me difficulty.

const Func = () => {
  return () => {
    console.log('hello');
  };
};

const innerFunc = Func();

innerFunc(); // 1.

Func(); //2.

I don't understand why 'hello' doesn't show up on console trying with 2.

Aren't both innerFunc and Func names of function?

I don't know the difference between them.

Sorry for my bad English.

about 4 years ago · Juan Pablo Isaza
3 Respostas
Responde à pergunta

0

Func() returns a function which will not be executed until you run the result with () like you are doing with 1..
By doing const innerFunc = Func();, you are assigning the function returned from Func into innerFunc. So to call it, you need to run it like this: innerFunc().

about 4 years ago · Juan Pablo Isaza Relatório

0

Your function 'Func' returns another function from inside, so when you call Func(), then it will return another function which you named as 'innerFunc' and calling innerFunc will return the output as hello.

When you try with Just 'Func()', it will just return another function which you returned inside Func.

about 4 years ago · Juan Pablo Isaza Relatório

0

Starting to learn about functions, just look at

const Func = () => {
    console.log('hello');
};

Func(); // logs hello to the console

What you have here is a function inside of function, which is more complicated and not necessarily beginner friendly.

about 4 years ago · Juan Pablo Isaza 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