Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.javascript > #27938

Re: Expression for the global object

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 <ben.usenet@bsb.me.uk>
Newsgroups comp.lang.javascript
Subject Re: Expression for the global object
Date Sun, 31 May 2015 11:20:19 +0100
Organization A noiseless patient Spider
Lines 27
Message-ID <87oal1hwv0.fsf@bsb.me.uk> (permalink)
References <JavaScript-20150528222318@ram.dialup.fu-berlin.de> <Function-20150531095026@ram.dialup.fu-berlin.de> <Function-20150531095945@ram.dialup.fu-berlin.de>
Mime-Version 1.0
Content-Type text/plain; charset=iso-8859-1
Content-Transfer-Encoding 8bit
Injection-Info mx02.eternal-september.org; posting-host="017616aa25f81ec581c44d76d61ba2f3"; logging-data="30512"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/3yCLfCgopubjoxFYQWIIYvf52OXEF1Aw="
Cancel-Lock sha1:zDeqdDcWupQlJ6HkV+gwcYD+jFY= sha1:My1DuSULAhMhHkzrcbVSCdVynvY=
X-BSB-Auth 1.759e9d92410e8125c9b1.20150531112019BST.87oal1hwv0.fsf@bsb.me.uk
Xref csiph.com comp.lang.javascript:27938

Show key headers only | View raw


ram@zedat.fu-berlin.de (Stefan Ram) writes:

> ram@zedat.fu-berlin.de (Stefan Ram) writes:
>>In the superseded post, I wrote:
>>|ram@zedat.fu-berlin.de (Stefan Ram) writes:
>>|>What is the smallest scope- and host-independent expression
>>|>whose value is the global object?
>>|Function("return this")()
>>But this will not work when »Function« has another meaning
>>in the current scope!

I should have read on before posting because you made the same remark
that I did about your example.  Sorry about that.

>   However, most JavaScript tutorials assume for their code
>   examples that the meaning of essential global objects like
>   »Function« or »console« is nowhere being redefined.
>   So, under these »normal conditions«, it should work.

But your original motivation was for an expression that worked in
unusual situations where such things have not been redefined.  There's
an expression that does what you want that does not use any identifiers,
but it fails (as Thomas pointed out) in strict code.  I don't think
there is a solution but I can't prove it.

-- 
Ben.

Back to comp.lang.javascript | Previous | Next | Find similar | Unroll thread


Thread

Re: Expression for the global object Ben Bacarisse <ben.usenet@bsb.me.uk> - 2015-05-31 11:20 +0100

csiph-web