Jul 23, 2017 · 1 min read
I’m late coming back and replying to this comment, but it seems like you’re using the term “pure function” wrong, both in the above comment and in the article. You talk as if a pure function, by definition, cannot use “this”. But that’s not the case. For example, each of the following functions are equally pure:
function setName(person, strName) {
return Object.assign({}, person, {name: strName})
}
function setName(this_, strName) {
return Object.assign({}, this_, {name: strName})
}
function setName(strName) {
return Object.assign({}, this, {name: strName})
}Whether we use “this” or not, and whether our function is pure or not, are two completely independent qualities.
