Personal reference to learn and understand the js features with real usecases, tips and tricks, examples
Imperative programming performs an action/mutation/side-effect.It tells the control flow.
Expresses the logic of a computation without describing its control flow.
A function or expression is said to have side-effects if it modifies some state variables outside it local environment. The outside environment could be browser, i/o service etc
Variable capable changing the state of the environment.
Side effects are necessary, because thats how app responds. But how to handle them effectively is what different programming differs
Object-oriented programming makes code understandable by encapsulating moving parts. Functional programming makes code understandable by minizing the moving parts.
Here moving parts
is the side-effects and each paradigm handles them differently
- Encapsulation (OOP)
- Separate logic from action (Functional)
Imperative - Encapsulation - Declarative.
Encapsulate Imperative code and hack away the logic in to declarative code to minimize the imperativeness