Your example #4 is a classic case of "variable for nothing". Though that goes hand in hand with the derpitude of using LET to build functions, and the painfully cryptic and ultimately pointless arrow function trash.

function generateBookObject(
name = 'JavaScript',
price = 12,
discount = 0.5,
genre = 'Technology'
) { return { name, price, discount, genre }; }

Seriously, lose the cryptic nonsense. Hence your #9 to me is hard to read hard to follow garbage that I just don't understand how people can say is clearer/better. NOT that I understand what your map functions have to do with either let since you don't use them.

Beware that for/of can be many times slower than a normal for loop. NOT as slow as Array.forEach, but still has piss poor performance by comparison, particularly if you store the length in a local first.

for (var i = 0, iLen = names.length; i < iLen; i++) {

Can be MANY times faster executing than for/of. Also if you know none of your array entries are loose false, you can do this:

for (var i = 0, name; name = names[i]; i++) {

And it's even faster executing. I like for/of for its clarity, but sometimes performance takes precedence. NOT saying don't use for/of, just be mindful of its limitations.

Backticks multiline strings are nice, but since like a LOT of the newer features they're not real world deployable client-side it might help to have also mentioned the trailing slash approach.

var greeting = "Hi, I am Amy\
I am a programmer.\
Nice to meet you.";

It's shocking how many JS dev's are unaware of that one, and it works all the way back to IE 5.

All that said the intent of the article is good, shame so much of it I just can't use since my clients are STILL (painfully, annoyingly) expecting at least IE 11 support, many still seem to think IE 8 is still relevant (whiskey tango foxtrot) and I'm not using JS server-side.

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