ecmascript 5 and the script tag

Allen Wirfs-Brock Allen.Wirfs-Brock at
Mon Apr 20 13:03:34 PDT 2009

There currently isn't any such API and it is debatable whether or not one is actually needed.

In most cases, "strict mode" will be explicitly specified in lexically enclosing code (ie, in the same source file) so the code hypothetically wanting to make this test should already know whether or not it is strict mode code.

The only situation where strict mode might not be lexically obvious would be code that is injected via a direct call to eval. The strictness of direct eval'ed code (that does not have a "use strict" directive) is determined by the strict mode of the caller of eval so if the source code passed to eval came from a "foreign" source it might not have been known when it was written whether or not is was going to execute in strict mode. 

There are a number of coding idioms that could be used to dynamically determine whether or not code is operating in strict mode. I guess the question really is whether those idioms are adequate for the above eval based scenario.


>-----Original Message-----
>From: es-discuss-bounces at [mailto:es-discuss-
>bounces at] On Behalf Of kevin curtis
>Sent: Friday, April 17, 2009 6:52 PM
>To: es-discuss at
>Subject: Re: ecmascript 5 and the script tag
>If a script (or Program) has the 'use strict' directive is there an
>api or flag for querying if the script is 'strict'. Both at the
>ecmascript level and at the api c/c++ level. Or should the developer
>(either in ecmascript or c/c++) examine the first line of source code
>for the 'use strict' directive. (The same goes for functions).
>es-discuss mailing list
>es-discuss at

More information about the es-discuss mailing list