One of the JavaScript golden rules is to use strict mode. It does tighten things up compared to the so-called “sloppy mode” and seems to generally be a good idea.
Strict mode has been around for a while (since 2009) and does a bit more than just throw more errors. In the docs, the impacts of strict mode are listed out:
* changes converting mistakes into errors (as syntax errors or at runtime)
* changes simplifying how variable references are resolved
* changes simplifying eval and arguments
* changes making it easier to write "secure" JavaScript
* changes anticipating future ECMAScript evolution.
To me, the best features are around enforcing variable declarations and eliminating duplicate parameter names. The non-leaking eval also seems like a nice improvement if you need to do that sort of thing.
Something I picked up from JavaScript for the Impatient is the invocation of strict mode in the Node REPL with the --use-strict
argument. That makes it easy to run in strict mode on the command line.