Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!1.eu.feeder.erje.net!newsfeed.fsmpi.rwth-aachen.de!newsfeed.straub-nv.de!eternal-september.org!feeder.eternal-september.org!mx02.eternal-september.org!.POSTED!not-for-mail From: Ben Bacarisse Newsgroups: comp.lang.javascript Subject: Re: Expression for the global object Date: Sun, 31 May 2015 15:57:11 +0100 Organization: A noiseless patient Spider Lines: 43 Message-ID: <87wpzohk1k.fsf@bsb.me.uk> References: <87twuthx5h.fsf@bsb.me.uk> <5452925.Zt9fTqAOub@PointedEars.de> <87382cj1f5.fsf@bsb.me.uk> <7546503.qSl4iIXIz1@PointedEars.de> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Injection-Info: mx02.eternal-september.org; posting-host="017616aa25f81ec581c44d76d61ba2f3"; logging-data="22590"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/W5eP0dzcbWYn0YAXYUddKhm9SmF9V7Gs=" Cancel-Lock: sha1:gPlgcjl+kcDhbGaQ76l5Twzwy3M= sha1:Kl0SSxu1uo+R7VRkA5t685lgfN8= X-BSB-Auth: 1.60b9196a79be83e2fc5a.20150531155711BST.87wpzohk1k.fsf@bsb.me.uk Xref: csiph.com comp.lang.javascript:27945 Thomas 'PointedEars' Lahn writes: > Ben Bacarisse wrote: > >> (function () { return eval; })()("this") > > In all respects equivalent to > > eval("this") > > which is equivalent to > > this Given: 'use strict'; console.log((function () { return eval; })()("this") === global); console.log(eval("this") === global); console.log(this === global); nodejs prints: NaN undefined undefined (global is nodejs specific, of course, but there are other simple ways to test the value). > which is why it does not return a reference to the global object, but the > “undefined” value, in strict function code that is not called as the method > of an object. > > Sure, but what does 15.1.2.1.1 (Direct Call to Eval) have to say about it? You can interpret the words there much more readily than I can, and it would seem that at least one implementation has decided that the evaluation of the thunk above is not a "direct call to eval". -- Ben.