r/javascript • • Aug 27 '16

Is your JavaScript function actually pure?

http://staltz.com/is-your-javascript-function-actually-pure.html
8 Upvotes

48 comments sorted by

View all comments

5

u/[deleted] Aug 27 '16 edited Aug 27 '16

This is a philosophical question. JavaScript almost exists in a quantum state where you cannot tell if it is pure or impure, unless you use the code. That pretty much sums up the article.

2

u/[deleted] Aug 28 '16

Except I don't think that's really true. Getting something's value is calling a function, so if that function's impure then yeah, any function that calls it will be impure. OTOH, as long as the function to get something's value is pure (ie 99.9% of cases) your pure function will actually be pure.