I am Software Developer, currently interested in static type languages (TypeScript, Elm, ReScript) mostly in the frontend land, but working actively in Python also. I am available for mentoring.
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 let for about 2 years and I was working with really big web system. And its not like I am against let, in my opinion we can use only let, only const or mix them and its ok. Mixing them is how it was design, you want to re-assign use let, you don't use const.
BTW. TypeScript differentiates these concepts, as for const the type narrowing is mor strict, and it means that if you have let the type can change, if you have const it can't change.
At my (yesterday last day of) job, we wrote an interactive, zoom/pan/drag SVG engine, using Typescript. 0 var, only const or let (and classes), to renew our previous, var full engine we wrote in JS.
Not to mention errors drastically dropped (500 lines long unminifed).
Depends. If you ever need to re-assign a value to a variable or use a for ... of or for ... in loop , 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.
How’s it going, I'm a Adam, a Full-Stack Engineer, actively searching for work. I'm all about JavaScript. And Frontend but don't let that fool you - I've also got some serious Backend skills.
Location
City of Bath, UK 🇬🇧
Education
11 plus years* active enterprise development experience and a Fine art degree 🎨
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.