JavaScript’s Next Evolution: “use stricter”;

Nick Gard
2 min readSep 6, 2019

--

Photo by Markus Spiske on Unsplash

The introduction of “use strict”; greatly cleaned up the language, but there’s still some pain points to eliminate. I think JavaScript is ready for “use stricter”;!

Disclaimer: This is not a real or upcoming feature of JavaScript, just my wishlist.

Stricter JavaScript

  • Optional chaining and function invocation by default. ?., ?[], and ?() are no longer necessary. Still want to blow up the whole app when traversing goes awry? Use the coalescing operator: uh.oh.spaghettio ?? throw new Error(‘burn it down’);.
  • null === undefined. Then you only have to check one value. Why the hell are there two “empty” values anyway?!
  • typeof null === ‘undefined’. In keeping with the above point.
  • 0 is truthy. NaN is the only falsy number we need.
  • Nothing coerces to a number. Use parseInt and parseFloat to coerce strings.
  • + is only for addition, not string concatenation. Use template literals instead.
  • Array.prototype.indexOf returns NaN (a falsy value!) for no matches, not -1.
  • No Automatic Semicolon Insertion. Stop being lazy, developers.
  • Only strict equality is allowed. == does the same as ===.
  • parseInt radix always defaults to 10. I mean, how many times have you meant for it to be 8 or 16?

Was there anything I missed? We can always put those things in the next breaking change of JavaScript: “use strictest”; 😆

--

--

Nick Gard
Nick Gard

Written by Nick Gard

Web Developer, Oregonian, husband

No responses yet