"use strict"; prepended blindly to scripts in the wild

Mike Shaver mike.shaver at gmail.com
Thu Sep 9 09:42:59 PDT 2010

On Thu, Sep 9, 2010 at 1:09 AM, Dmitry Soshnikov
<dmitry.soshnikov at gmail.com> wrote:
> Currently, a site may normally concatenate 3rd-party libs with "use strict"
> at the global level. The technique is the same as with forgotten semicolon
> -- just to put an empty statement at the beginning of the end file.
> Thus the site's combined file won't be globally strict, however since a lib
> is tested before a production release (at least I hope so ;), then the lib's
> code should pass the strictness, and therefore, a "use strict" may be even
> removed from the lib's file. However, if not to remove, then an empty
> statement is enough.

Unfortunately for this eminently reasonable (IMO) assumption, removing
"use strict" can change the behaviour of a program, even beyond cases
that would have thrown an error.  For example, the type and value of
|this| can be different, for cases where methods are called on

I don't know if other languages with optional strictures share this
property, but I suspect that a lot of people are going to stub their
toe on ES5's use of "use strict" as cover for incompatible changes
rather than strictly subsetting legal programs and behaviours. :-/


More information about the es-discuss mailing list