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

199
Vistas
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 Respuestas
Responde la pregunta

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 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