4 ms·
I appreciate there's something I'm missing, but: I use closures to hold state all the time in node, I still don't understand why state in a closure is better t
by nailer 11y ago
I appreciate there's something I'm missing, but:
I use closures to hold state all the time in node, I still don't understand why state in a closure is better than state in an object.
If someone could explain this I'd be grateful: articles like this just seem to say 'state is bad' and ignore that it still exists in functional scopes.
- pvdebbe 11y agoIt's not really state if it's immutable. Not the case with node, but closures in general match the notion of parameterized functions (like f_a(x)).
- seabee 11y agoState in a closure is equally as bad as state in an object. The difference is FP gives you ways to manage and isolate state that simply don't exist in OOP.
- deleted 11y ago[deleted]
- deleted 11y ago[deleted]