Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

122
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!