5.2 - Encapsulation
Encapsulation is a technique where we restrict access to some local state to only be accessible from within its local scope, effectively protecting it from any access from outside that scope. So, what does this have to do with side effects? It affects one particular special case of side effects: mutable state. Consider one of our first examples, a sum of all the numbers in an array: let sum = function(array){ let result = 0; for(let i = 0; i < array....