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

113
Visualizações
Is there a way to use a variable inside an arrow function but initialize it inside another function where the arrow function is also called?

I'm trying to access the variable c that is initialized inside myFunc when I call sum.

let sum = (a,b) => {
    let result = a + b + c;
    return result;
}

function myFunc(){
    let c = 5;
    return sum(1,2);
}

console.log(myFunc());

But I'm getting an error because of the c that I use inside the arrow function. Don't know if I'm explaining right but I think you get the point by seeing the code above.

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