DEV Community

Discussion on: Should Pure Functions Be Self-contained

Collapse
 
vonheikemen profile image
Heiker • Edited

Fair question. This is javascript, right? In a dynamic language you can only write code in a functional style and hope that no one does a trick like the one you did there.

In your example inner becomes impure because valueOf is impure (it changes some state outside of its scope). So if an impure function gets executed inside of a "pure" function than it is no longer pure.