by logicalmonster · 3y ago · 0 comments
That said, you should also think in terms of "What does JavaScript have that functional programming doesn't?". As a working-stiff programmer, most of the time the problems you're going to encounter are going to be a lot easier and faster to solve if mutating state is available as an option.
For example, feel free to use mutation if it's limited to the implementation of a small function. The function will still be effectively pure (to callers of the function).
Or when implementing "functional core, imperative shell," Gary Bernhardt says he tends to start with imperative code in the shell, then refactor it into the functional core[1].
As for mutating state, I come from an embedded software (microcontrollers) background haha and there's no option but to mutate state