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
Henrique Emanoel Viana -
Nik L. -
Rajesh Dhiman -
Vinod Chandra -
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
let
for 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
, onlyconst
or 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
const
the type narrowing is mor strict, and it means that if you havelet
the type can change, if you haveconst
it can't change.At my (yesterday last day of) job, we wrote an interactive, zoom/pan/drag SVG engine, using Typescript. 0
var
, onlyconst
orlet
(andclass
es), to renew our previous,var
full 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 ... of
orfor ... 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.Yes absolutely
I think so. You can still mutate objects assigned to consts, assign them functions and use recursion to avoid loops.