With great flexibility comes great responsibility… and JavaScript is very flexible. Too flexible, some might argue. There are many “features” of JavaScript that result in code that is hard to read, dangerous or buggy to execute, and in some cases creates performance issues. In 2008, Douglas Crockford wrote a fantastic book called “JavaScript: The Good Parts” that described the features he found problematic: global variables, the assignment of ‘this’ to the global object, misuse of eval, etc. If you write JavaScript, it’s a must read.
Several of the “bad” features Crockford identified have been mitigated with “Strict Mode.” This was added to version 5 of ECMAScript (the JavaScript standard; supported by most popular web browsers). Strict mode throws exceptions or prevent behavior when “bad” features or common coding errors are evaluated. A couple of examples…