I’m not too interested in describing the paradigms in and of themselves. I’ll defer you to Eric Elliot’s article on the basics of functional programming, and for object-oriented programming, this older but more principled primer on object-oriented programming.
In the OOP world, that power is the ability to encapsulate complexity and delegate responsibilities to those containers of completexity, keeping your code losely coupled and highly organized. The cost, however, is the freedom to ignore SOLID principles and create deep hierachies, tight coupling, and a lot of state whose values we can barely enforce without a type system. For that last problem, we have options like TypeScript or Flow that can assist in the prevention of “a is undefined” type runtime errors by ensuring that code is operating on what it expects.
If I were to sum up these ideas:
- OOP - With great power comes great responsibility
- FP - With great constraint comes great power
I will admit that I have a bias for OOP as we have decades of lessons in the paradigm that can be applied in a JS context without any libraries. In FP, we absolutely have patterns in concepts like Functors, Applicatives, Monads, etc. The issue in JS is that these must be provided by a library or built yourself if you want access to their power.
Some functional concepts have arrived in JS. Map, reduce, and filter allow us more declaritive, functional means of processing collections. And JS has always been functional in the sense that functions are first-class members of the language, and can be passed around as arguments to other functions, allowing higher-order functions to emerge. Using Object.freeze, we can make immutable structures and keep our state management lower.
Hopefully, you’ll look at the links provided throughout and come to your own conclusions.