What is a side effect in JavaScript?
A side effect is any application state change that is observable outside the called function other than its return value. For example modifying any external variable like global variable, logging to console, writing to file, writing to network, calling other functions with side effects.
Side effects are mostly avoided in functional programming, which makes the program easier to understand and to test.
References:
- Master the JavaScript Interview: What is Functional Programming?
- 3 common approaches to side-effects in Redux apps
- Redux side effects and me
- Preventing Side Effects in JavaScript
- HOW TO DEAL WITH DIRTY SIDE EFFECTS IN YOUR PURE FUNCTIONAL JAVASCRIPT
- Dealing with side effects and pure functions in javascript
Categories :
JavaScript