What do you think?
For further actions, you may consider blocking this person and/or reporting abuse
What do you think?
For further actions, you may consider blocking this person and/or reporting abuse
Anton Zamay -
Will T. -
Evotik -
Ran Tu -
Top comments (5)
There are languages where you cannot re-assign (what const is exactly about) but even you cannot mutate (what const is not about), and still you can write any kind of software in these languages.
And in JS perspective, I didn't use
letfor about 2 years and I was working with really big web system. And its not like I am againstlet, in my opinion we can use onlylet, onlyconstor mix them and its ok. Mixing them is how it was design, you want to re-assign uselet, you don't useconst.BTW. TypeScript differentiates these concepts, as for
constthe type narrowing is mor strict, and it means that if you haveletthe type can change, if you haveconstit can't change.At my (yesterday last day of) job, we wrote an interactive, zoom/pan/drag SVG engine, using Typescript. 0
var, onlyconstorlet(andclasses), to renew our previous,varfull engine we wrote in JS.Not to mention errors drastically dropped (500 lines long unminifed).
So yes it is possible!
Depends. If you ever need to re-assign a value to a variable or use a
for ... oforfor ... inloop , the answer is no. If you do not, then the answer is yes. Sometimes it's unavoidable, and even if it were avoidable, that may not necessarily be the right move.Yes absolutely
I think so. You can still mutate objects assigned to consts, assign them functions and use recursion to avoid loops.