3 ms·
If a function is pure, it can take in and output 100% unmodifiable values. There will never be any side-effects in a pure function. In other words, if you need
by entropicdrifter 2y ago
If a function is pure, it can take in and output 100% unmodifiable values. There will never be any side-effects in a pure function.
In other words, if you need to modify the contents of a variable for a function to run, that's not a pure function. Taking something in and outputting something just like it but with some modifications is allowed, so long as the input is unmodified.
Does that make more sense? You can't modify anything inside a function that originated from outside of the function's scope.
- betenoire 2y agoI think they understand that, and are referring to more nuanced side effects. Logging, for an example, is a side effect, same with even using a date function. Hitting an API endpoint without cache may be functional if the response never changes, but do you want that? Usually we want a cache, which is skirting idempotency. The closer you look, the more side effects you see