Jason Knight
2 min readOct 4, 2020

Your "so confusing" first example is how most languages I was taught worked... I never liked block level scoping and always found function scope MORE than adequate. All this let/const crap just confusing something that -- to my experience and background in languages like Assembler, Pascal and Ada -- is just the natural order of things.

I still say if you "need" block level scoping like that provided by "LET" your code is either too complex, or just plain poorly thought out.

Same for the "don't use = in your if statement" which should more be "learn the difference between =, ==, and ===". Saying "don't" to a perfectly valid and useful construct amounts to little more than pedantic nitpicking. This is particularly true if you go beyond "if' and into "while' where testing the result of assignment is really REALLY useful.

The people who get upset at something like:

if (e = e.firstElementChild) do {
/* do something with E here */
} while (e = e.nextElementSibling);

... generally needing to back the fork away from the keyboard and go take up something a bit less detail oriented like macramé.

But again, most people from C syntax backgrounds often lose their minds when they see how REP or LOOP works in assembler. Particularly if they bought the bald faced LIE that C is somehow “‘”closer to how machine langauge works” — it isn’t. As evidenced by the optimal loop in machine language is typically the equivalent of this C code:

dword ecx = 30;
do {
/* whatever */
} while (--ecx);

aka:

MOV ECX, 30
:loopStart
; whatever
loop :loopStart

Or on processors that lack LOOP or DEC

LD R3, 30
:loopStart
; whatever
SUB R3, 1
BVC :loopStart

Evaluate on assignment, USE IT! People need to learn what it is, instead of crying “Wah wah, eye dunz knows it sew nubuddie elze shud!”

Jason Knight

Accessibility and Efficiency Consultant, Web Developer, Musician, and just general pain in the arse