• Empleos
  • Sobre nosotros
  • profesionales
    • Inicio
    • Empleos
    • Cursos y retos
  • empresas
    • Inicio
    • Publicar vacante
    • Nuestro proceso
    • Precios
    • Evaluaciones
    • Nómina
    • Blog
    • Comercial
    • Calculadora de salario

0

176
Vistas
Why are anonymous functions passed into variables?

So, I'm using freecodecamp and it says that the following function is anonymous:

const myFunc = () => {
  const myVar = "value";
  return myVar;
}

console.log(myFunc.name);

Well, how come it's anonymous if its name is clearly "myFunc"?

almost 3 years ago · Santiago Gelvez
1 Respuestas
Responde la pregunta

0

You are setting myFunc to reference an anonymous function. myFunc has a name, the anonymous function it references does not.

const myFunc = () => {
  const myVar = "value";
  return myVar;
}

// This returns myFunc name
console.log(myFunc.name);

// This returns anonymous function's name which is blank
console.log(
(() => {
  const myVar = "value";
  return myVar;
}).name
);

almost 3 years ago · Santiago Gelvez Denunciar
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 Nuestro proceso Comercial
Legal
Términos y condiciones Política de privacidad
© 2025 PeakU Inc. All Rights Reserved.

Andres GPT

Recomiéndame algunas ofertas
Necesito ayuda