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

172
Vistas
Can curry functions be executed half way?

Lets say I have a function like this:

function foo(){
  return () => {
    return "bar"
  }
}

foo()() // => "bar"

Is there a way for this to return something other than a function without the use of a parameter?

foo()() // => "bar"
foo()   // => "foo"
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

No. If the value returned must be callable later, then it has to be a function - no exceptions.

You could put a property on the function, though.

function foo(){
  return Object.assign(
    () => {
      return "bar"
    },
    { prop: 'bar' }
  );
}

console.log(foo()());
console.log(foo().prop);

Or return both a function and something else.

function foo(){
  return [
    () => {
      return "bar"
    },
    'bar'
  ];
}

const [fn, val] = foo();
console.log(fn());
console.log(val);

about 4 years ago · Juan Pablo Isaza 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 Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda