“JavaScript’s a mess – and that’s a good thing” – 2ality

Saving this info for later.

A cleaner JavaScript

If you want to program in as clean a JavaScript as possible, there is much you can ignore (some suggestions are more radical than others):

  • var. Use let and const, instead.
  • function. Use only arrows and method definitions. Benefit: handling this becomes much simpler (details).
  • Promises. Use only async functions. Learn what to watch out for (you can’t ignore Promises as completely as var).
  • Iterating over objects. Use Maps, instead.
  • Loops: for-in (avoid always), for (avoid if you can). Use for-of, instead.
  • arguments. Use rest parameters (...args), instead.
  • Function.prototype.apply(). Use the spread operator (f(...myArray)), instead.
  • Constructor functions. Use classes, instead.
  • IIFEs. Use blocks, instead.

From this great JS blog.



Import statements snippet for VS Code


Leave a Reply

Your email address will not be published. Required fields are marked *