"no strict"; directive

Oliver Hunt oliver at apple.com
Fri Nov 16 15:32:43 PST 2012

I don't think you understand the semantics here -- the Function constructor is defined as taking a string (ignoring the parameters for now) and returning a function as though the function was defined in the global scope.  No functions change behaviour based on the strictness of their caller.  The only way to make a string execute as javascript inside the scope of another function is to use the eval _operator_.  These are fundamentally different concepts.

To put it another way, if the Function constructors behaviour was dependent on the strictness of its caller, i would expect:
document.write("<script>/*code here*/</"+"script>");

to produce an script element that was already in strict mode.

You really need to read the spec, as you seem to be misunderstanding some very fundamental concepts.


On Nov 16, 2012, at 3:19 PM, Andrea Giammarchi <andrea.giammarchi at gmail.com> wrote:

> back in the topic ... about evaluation: Function('return this')(); returns the global object with or without use strict around. This is actually nice, since this one was a security problem introduced when somebody decided that `this` without an explicit context should have been undefined. Now it is possible to retrieve the global object as long as Function is the original constructor.
> Said that, I believe this is a bug in every browser. (Webkit, FF, Chrome suffering)
> Please do not fix, thanks :-)
> On Fri, Nov 16, 2012 at 2:50 PM, Andrea Giammarchi <andrea.giammarchi at gmail.com> wrote:
> love this answer, thanks!
> On Fri, Nov 16, 2012 at 2:47 PM, Jeff Walden <jwalden+es at mit.edu> wrote:
> On 11/16/2012 02:37 PM, Andrea Giammarchi wrote:
> > what I am saying: arguments won't disappear in 5+ years, neither will caller ... is my crystal ball correct?
> It's not necessary for these things to disappear completely for us to derive value from these decisions.  It's only necessary for good code, that wants to be performant, to not use them.
> Jeff
> _______________________________________________
> es-discuss mailing list
> es-discuss at mozilla.org
> https://mail.mozilla.org/listinfo/es-discuss

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20121116/2545bb36/attachment.html>

More information about the es-discuss mailing list