global object in strict mode

Andrea Giammarchi andrea.giammarchi at gmail.com
Thu Aug 23 18:41:52 PDT 2012


the non eval solution for ES3 is

var global = function(){return this}();

and not with eval ...

In ES5 usually window is not writable/configurable but enumerable so
theoretically you can rely in the `window` object unless your code is not
evaluated through eval inside a function with a window variable redefined.

On Thu, Aug 23, 2012 at 11:59 PM, John J Barton <johnjbarton at johnjbarton.com
> wrote:

> Long ago this list had a subject:
>
> How to retrieve the global object in strict mode?
> https://mail.mozilla.org/pipermail/es5-discuss/2011-February/003919.html
>
> Roughly the conclusion was:
>
>   var global = ("global", eval)("this");
>
> However Content Security Policy
>
>
> https://dvcs.w3.org/hg/content-security-policy/raw-file/tip/csp-specification.dev.html
>
> bans 'eval', (as well as all similar forms) making this solution fail.
>
> Is there a non-eval based solution?
>
> jjb
> _______________________________________________
> 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/20120824/afbdf046/attachment.html>


More information about the es-discuss mailing list