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


Groups > comp.lang.javascript > #27919

Re: Expression for the global object

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!1.eu.feeder.erje.net!news.albasani.net!weretis.net!feeder1.news.weretis.net!news.solani.org!.POSTED!not-for-mail
From Thomas 'PointedEars' Lahn <PointedEars@web.de>
Newsgroups comp.lang.javascript
Subject Re: Expression for the global object
Date Fri, 29 May 2015 13:33:25 +0200
Organization PointedEars Software (PES)
Lines 36
Message-ID <15438118.NDL39TPNyL@PointedEars.de> (permalink)
References <JavaScript-20150528222318@ram.dialup.fu-berlin.de> <645d86ba-2299-4371-bb64-90dae6df316a@googlegroups.com> <cspehuFliqhU1@mid.uni-berlin.de> <5567f976$0$12987$c3e8da3$5496439d@news.astraweb.com> <87k2vrmxr4.fsf@bsb.me.uk>
Reply-To Thomas 'PointedEars' Lahn <cljs@PointedEars.de>
Mime-Version 1.0
Content-Type text/plain; charset="UTF-8"
Content-Transfer-Encoding 8Bit
X-Trace solani.org 1432899364 7392 eJwNwoERADEEBMCaxDmUE0T/JfzPrimF7aARtrYuPxLRT1M3F9N9LfSesEoMXo0zpNT9ZH4PBBCY (29 May 2015 11:36:04 GMT)
X-Complaints-To abuse@news.solani.org
NNTP-Posting-Date Fri, 29 May 2015 11:36:04 +0000 (UTC)
User-Agent KNode/4.14.2
X-User-ID eJwFwQEBACAIA7BKgv/FOIjYP4Ibp0y1IAp8fDHqJAfC0q1m0pqEN84d+7ZPsu7ZUj5DsqJWJ6SI5dhuH0qaFPk=
Cancel-Lock sha1:W3eR5tvzhF6/Ren4SL0vhtaVbak=
X-NNTP-Posting-Host eJwFwQkBwDAIA0BLPAl0cqAM/xJ6Rw+NmwgGuNym6TGY6AeEm3C41Tr+13a6b08IyXORJfMAAKQQjA==
Xref csiph.com comp.lang.javascript:27919

Show key headers only | View raw


Ben Bacarisse wrote:

> […]  I think
> you can get a reference to the global object in any execution context
> using the rather convoluted
> 
>   (function () { return this; }).call(null)
> 
> expression.

You are wrong.

> There might be some cases where this might be used in code,

There are.

> but it does not meet Stefan's other criterion as it is far too unwieldy
> to use in text.

Pardon?

> This works because a null value for 'this' is replaced by the global
> object when entering function code (10.4.3)., though the twisty passages
> of the standard always leave me a little unsure about corner cases.

AISB, in strict mode this function returns the “undefined” value.

Strict mode is not a "corner case" anymore.

It is _not_ going to work this way.

-- 
PointedEars
FAQ: <http://PointedEars.de/faq> | SVN: <http://PointedEars.de/wsvn/>
Twitter: @PointedEars2 | ES Matrix: <http://PointedEars.de/es-matrix>
Please do not cc me. / Bitte keine Kopien per E-Mail.

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


Thread

Re: Expression for the global object "Michael Haufe (TNO)" <tno@thenewobjective.com> - 2015-05-28 13:49 -0700
  Re: Expression for the global object Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2015-05-28 22:59 +0200
    Re: Expression for the global object "Michael Haufe (TNO)" <tno@thenewobjective.com> - 2015-05-29 07:24 -0700
      Re: Expression for the global object Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2015-05-29 17:24 +0200
        Re: Expression for the global object "Michael Haufe (TNO)" <tno@thenewobjective.com> - 2015-05-30 06:07 -0700
          Re: Expression for the global object Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2015-05-30 15:20 +0200
            Re: Expression for the global object Joao Rodrigues <groups_jr-1@yahoo.com.br> - 2015-05-30 11:23 -0300
              Re: Expression for the global object Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2015-05-30 19:05 +0200
  Re: Expression for the global object Steven D'Aprano <steve@pearwood.info> - 2015-05-29 15:30 +1000
    Re: Expression for the global object Ben Bacarisse <ben.usenet@bsb.me.uk> - 2015-05-29 12:25 +0100
      Re: Expression for the global object Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2015-05-29 13:33 +0200
        Re: Expression for the global object Steven D'Aprano <steve@pearwood.info> - 2015-05-29 21:50 +1000
          Re: Expression for the global object Ben Bacarisse <ben.usenet@bsb.me.uk> - 2015-05-29 14:57 +0100
            Re: Expression for the global object Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2015-05-31 16:18 +0200
  Re: Expression for the global object "Michael Haufe (TNO)" <tno@thenewobjective.com> - 2015-05-29 07:31 -0700
    Re: Expression for the global object Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2015-05-30 15:25 +0200
  Re: Expression for the global object Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2015-05-30 18:56 +0200

csiph-web