JavaScript is a multi use language
- OOP
- Functional way
With JS, you can use functional programming techniques in code that follow OOP paradigm. And you can use objects in code that follow FP paradigm.
Eric Elliott - "Functional programming is the process of building software by composing pure functions, avoiding shared state, mutable data and side effects." "FP is declarative than imperative, and application state flows through pure functions"
Functional Programming :-
- Avoids side-effects
- Avoids Mutations
- Avoids shared state
- Uses pure functions
- Uses Function compositions
- Use declarative code rather than imperative code.
Understand each of these terms, and understand principles and techniques for FP:-
-
JS was not just written for FP approach. At times, you should use short-cut with functional approach. Since JS does not do very well in certain things that FP approach has.
-
Avoiding Side effects by using Pure functions:- a.