Search code examples
javascriptinterpreteruse-strict

Why isn't "use strict" default?


Why isn't "use strict" the default way to interpret ES6 javascript, preferring the functionality: "do not use strict" (or whatever) to turn it off?

Previously, I imagined "use strict" as sort of like Safe Mode in macOS (only to be turned on when necessary, and then only temporarily), but I have since learned that it is recommended by many developers to use "use strict" for basically everything in javascript.

So, if it's the recommended default, why isn't it an actual default for interpreters?


Solution

  • For backward compatibility. Old code that doesn't opt in to strict mode must still work.

    Notice however that the main new ES6 features actually do imply strict mode, so yes it is on by default in modern code (which uses ES6 module syntax).