3 ms·
We are on the same page. My point is having 2 let or var statements doesn't actually do anything on the interpreter side. If JS allowed 2 var/lets without com
by addicted 7y ago
We are on the same page.
My point is having 2 let or var statements doesn't actually do anything on the interpreter side.
If JS allowed 2 var/lets without complaining, it would be entirely a social convention as to what that meant, since it would have no effect on the actual code that was run.
And the social convention benefit (which could more easily be achieved with just putting a comment at the end) is probably far outweighed by the many, real examples I've seen where someone has accidentally created a new variable without realizing that variable already exists in scope.
Disallowing multiple vars helps linters identify these situations (which are far more common with var's function level scoping than let's block level scoping).