Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.javascript > #27938 > unrolled thread
| Started by | Ben Bacarisse <ben.usenet@bsb.me.uk> |
|---|---|
| First post | 2015-05-31 11:20 +0100 |
| Last post | 2015-05-31 11:20 +0100 |
| Articles | 1 — 1 participant |
Back to article view | Back to comp.lang.javascript
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
Re: Expression for the global object Ben Bacarisse <ben.usenet@bsb.me.uk> - 2015-05-31 11:20 +0100
| From | Ben Bacarisse <ben.usenet@bsb.me.uk> |
|---|---|
| Date | 2015-05-31 11:20 +0100 |
| Subject | Re: Expression for the global object |
| Message-ID | <87oal1hwv0.fsf@bsb.me.uk> |
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 top | Article view | comp.lang.javascript
csiph-web