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

198
Visualizações
What is replacing .then(data => console.log(data)) with just .then(console.log) called?

I saw the following code in a React application.

getData()
        .then(res => res.json())
        .then(console.log)

And it behaves exactly the same as I would use

getAllStudents()
        .then(res => res.json())
        .then(data => console.log(data))

So in the first example the called function console.log somehow implicitly knows it should take the data as parameter and show it in the console. That function is not even called with console.log()

Could you please tell me what this shortcut concept is called? I would like to read more about it, but I don't know how exactly I should use it.

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

It is called "point free style" or tacit programming.

See e.g. https://en.wikipedia.org/wiki/Tacit_programming

Edit: The above case may not exactly be tacit programming, as that involves defining functions without explicitly mentioning their arguments ("tacit" = "implicit"), and here you are merely using an already defined function as an argument. But a function definition

const log = console.log

would be a tacit function, as opposed to

const log = data => console.log(data)

so the concept is at least closely related to the difference in the question.

about 4 years ago · Juan Pablo Isaza 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