Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

112
Vistas
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 la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda