Couple nitpicks...

On the subject of scope, I find the "need" of let/const to be utterly pointless. Maybe it's because after learning machine language decades ago my first high level language was Pascal, but really if you need more than "function level scope" there is something horrifyingly wrong with your code logic and/or naming conventions.

... and I quite often want variables outside their declaration, such as in a for loop I might want the iterator after I exit the loop. What am I to do, move the let to before the loop basically declaring it twice or making the look confusing by starting with a semi-colon?

Much less the stupidity of introducing LET's excess overhead right after immediately opening a function, where it does nothing VAR doesn't provide.

Var is far more versatile, has far, FAR less overhead, and if you need what let and const offer it's highly likely you're doing something wrong!

But then I still forward declare all function variables in C since I find block scope a pain in the ass there as well, so what do I know?

Still, to me LET and CONST are pointless additions to the language I cannot concieve the need of. It reeks of bad ideas from other languages being shoe-horned in where they don't belong.

I think it would also benefit your article if you mentioned "instanceof" as an alternative to "typeof". So often I see people checking for the wrong one of these, and I've even seen entire "library" functions created just to get around something so blasted simple.

"instanceof" being absolutely killer since it can detect inheritance as well... For example a = "1"; our "a" variable is instanceof both String and Object. Or a SELECT element node is instanceof Object, Node, Element, and HTMLSelectElement. The hoops I've seen people jump through just becasue they don't know that.

Otherwise, good article.

Written by

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store