Re:Constantly Confusing ‘const’
by megaman22 on Tuesday September 08, 2015 @03:50PM
(#10187827)
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?
[ Parent
| on HN ]
Yeah, 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.
Re:Constantly Confusing ‘const’
by jdeisenberg on Tuesday September 08, 2015 @04:14PM
(#10187964)
The 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?)