←back to thread

498 points azhenley | 1 comments | | HN request time: 0s | source
Show context
TheRoque ◴[] No.45772138[source]
I also default to const in javascript. Somehow a "let" variable feels so dirty, but I don't really know why. I guess at this point my experience forged an instinct but I can't even put a theory on it. But it's sometimes necessary and I use it of course.
replies(2): >>45772627 #>>45773213 #
1. maleldil ◴[] No.45773213[source]
JS's const doesn't go far enough since you can still mutate the object via its methods. In C++, you can only call const methods (which can't mutate the object) on const variables.