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

190
Vistas
Can we pass objects to function parameters in functional programming?

I have been mostly writing Object-oriented code in my day to day work and have little experience with functional programming.

In JavaScript/typescript code, we can definitely pass objects as parameters to functions. My question is whether passing objects to functions violates the functional programming paradigm as I am mixing object oriented code with functional style programming. (Even though The object passed into the function does not get mutated).

For example, if I have a function f(x,y) => z where x is an object that defines some interface. Object x makes a network call to access some resource which is used to compute z. We can say that such a function still adheres to the functional programming concept of it having no side effects and it being pure even though there is mixing of OO code in the function parameter ?

Hope my question was clear.

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

0

if I have a function f(x,y) => z where x is an object that defines some interface. Object x makes a network call to access some resource which is used to compute z.

If x makes a network call and uses the result to compute z, then it's (by most definitions) non-deterministic (since it performs I/O) and thereby not a pure function. This further means that f is impure, too. I don't consider that FP. Rather, it's an attempt at Dependency Injection.

This doesn't mean, however, that you can't pass 'data structures' as parameters - they just have to be immutable or other pure functions.

If, instead, object x implemented an interface that defines a pure function (an algorithm, say), you can pass it as a parameter, use the pure function, and the function that uses the 'object' might still be pure.

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