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

123
Vistas
Typescript Question:Functiong Type in Typescript Exercise 14

I am learning typescript in typescript exercise

in this subject solution,there is a function:

function toFunctional<T extends Function>(func: T): Function {
  const fullArgCount = func.length;
  function createSubFunction(curriedArgs: unknown[]) {
    return function(this: unknown) {
      const newCurriedArguments = curriedArgs.concat(Array.from(arguments));
      if (newCurriedArguments.length > fullArgCount) {
        throw new Error('Too many arguments');
      }
      if (newCurriedArguments.length === fullArgCount) {
        return func.apply(this, newCurriedArguments);
      }
        return createSubFunction(newCurriedArguments);
      };
   }
   return createSubFunction([]);
}

I dont understand this line:

const fullArgCount = func.length;

cause in that after,parameter func is a function,but whats the value of func.length ?

and whats newCurriedArguments actually mean ?

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

and whats newCurriedArguments actually mean ?

const newCurriedArguments = curriedArgs.concat(Array.from(arguments));

newCurriedArguments is the result of concatenating two arrays:

  1. curriedArgs from createSubFunction() function, as the inner function where newCurriedArguments is declared has access to its parent function variables, and curriedArgs is one of them.
  2. arguments which is the arguments of the function itself.

So you could say newCurriedArguments is the arguments of both the function and its parent.

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