3 ms·
What is the goal of marking that function const? Is it to prevent redefining the function, or as a hint that it is a pure function and it's outputs can be memo
by megaman22 11y ago
What is the goal of marking that function const? Is it to prevent redefining the function, or as a hint that it is a pure function and it's outputs can be memoized?
- _getify 11y agoYeah, see, this is exactly the problem. I think most developers assume the latter, when the former is all that's meant according to JS. I don't think the former is all that useful, and the latter is super useful but `const` doesn't do anything to help with that.
- jdeisenberg 11y agoThe fact that you can redefine a function gives me a terribly unsettled feeling, probably because I remember the assembly language days when we were told not to write self-modifying code, as it's not re-entrant. (If JS were ever in a concurrent environment, would re-defining functions lead to problems?)