A side effect is an externally observable change caused by executing code. Reading or modifying shared state, writing to the DOM, logging, and database access can make a function’s result depend on what happens outside its arguments. section 1.2
An unpredictable counter
The increment function changes the external variable counter, so another operation can alter its next result. Passing the counter in instead avoids that dependency: var increment = counter => counter + 1; section 1.2
Common side effects in the examples include:
- Updating an HTML element with innerHTML. section 1.2
- Reading a student from a database and throwing an error when it is missing. section 1.2
- Mutating an array during an imperative loop instead of producing a mapped result. section 1.2























