Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

301
Visualizações
how to pass argument to multiple lambda expressions in javascript?

can i give 2 argumens if there is multiple lambda funcionts in javascripts? i have the following code

var twice = (x) => {
  return x *x;
}

var lambda = (b) => { 
  (a) =>{
    return b(b(a));
  }
}; 


console.log(lambda(twice, 5));

this wont work, and I could use

  var lambda = (b,a) => { 
        return b(b(a));
    }; 

and will work, but can I use separate lambda expression and give them arguments ?

about 4 years ago · Santiago Trujillo
2 Respostas
Responde à pergunta

0

You can forward arguments to a function like this:

const twice = x => x * x;

const invokeFunctionWithArgs = (fn, ...args) => fn(...args);

console.log(invokeFunctionWithArgs(twice, 5)); // 25

about 4 years ago · Santiago Trujillo Relatório

0

Yes, You would take advantage of closures so that the inner function returned from invoking lambda() can keep a reference to its surrounding lexical environment.

You then call said inner function with the desired value lambda(twice)(5), in this case, 5.

var twice = (x) => {
  return x *x;
}

var lambda = (b) => { 
  return (a) => {
    return b(b(a));
  }
}; 


console.log( lambda(twice)(5) ); // -> 625

about 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda