Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.javascript > #24161
| From | Thomas 'PointedEars' Lahn <PointedEars@web.de> |
|---|---|
| Newsgroups | comp.lang.javascript |
| Subject | Re: intercept an alert |
| Date | 2014-05-12 19:35 +0200 |
| Organization | PointedEars Software (PES) |
| Message-ID | <10627210.CkprS3AAyM@PointedEars.de> (permalink) |
| References | (1 earlier) <raKdnSsnnK2Ow-3OnZ2dnUVZ_sadnZ2d@westnet.com.au> <3910370.hJEAF5dPUy@PointedEars.de> <8761lb47e7.fsf@gmail.com> <XnsA32B97AB9DD2Ceejj99@194.109.133.133> <window-20140512151357@ram.dialup.fu-berlin.de> |
Stefan Ram wrote:
> "Evertjan." <exxjxw.hannivoort@inter.nl.net> writes:
>> Simon Lewis […] wrote […]:
>>> People tag things on to "window" in each and every JS project.
>> You cannot know my JS projects, nor that of my neighbours,
>> so such utterances make your js-credulity go below 1% here.
>
> When one just defines a global function (which happens
> often) or variable, it becomes a property of the windows
> object.
You meant _window_, and no. It becomes a property of the ECMAScript global
object with the attribute [[DontDelete]] (ES3) or lacking the [[Writable]]
attribute (ES5.1+); see ES 5.1, §§10.2.3 and 10.4.1 [0]. Anything more
depends on the runtime environment and is not reliable (cross-frame
referencing excluded).
The ECMAScript global object can be referred to in the global execution
context with “this” because it is its /this/ value. Since there is no other
standards-compliant way, particularly not a built-in property, to refer to
the global object (yet) (returning the “this” value from an instantly called
anonymous function does not work in strict mode), it is recommended to
define a variable or property that can be used instead. For example:
var _global = this;
JSX provides “jsx.global” since several revisions in order to avoid another
global variable. [1] (The main compatibility layer, JSX:compat.js, can
still provide the old “_global” if needed. [2]) Of course, in properly
structured code it is only seldom necessary to refer to the global object
from local context in the first place.
____________
[0] <http://ecma-international.org/ecma-262/5.1/#sec-10.2.3>
<http://ecma-international.org/ecma-262/5.1/#sec-10.4.1>
[1] <http://PointedEars.de/wsvn/JSX/trunk/object.js>
[2] <http://PointedEars.de/wsvn/JSX/trunk/compat.js>
--
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
intercept an alert Andrew Poulos <ap_prog@hotmail.com> - 2014-05-12 14:38 +1000
Re: intercept an alert Andrew Poulos <ap_prog@hotmail.com> - 2014-05-12 15:35 +1000
Re: intercept an alert Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2014-05-12 11:32 +0200
Re: intercept an alert Simon Lewis <simonlewis2001@gmail.com> - 2014-05-12 12:29 +0200
Re: intercept an alert Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2014-05-12 13:30 +0200
Re: intercept an alert "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2014-05-12 14:54 +0200
Re: intercept an alert "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2014-05-12 15:36 +0200
Re: intercept an alert Simon Lewis <simonlewis2001@gmail.com> - 2014-05-12 15:40 +0200
Re: intercept an alert Simon Lewis <simonlewis2001@gmail.com> - 2014-05-12 15:43 +0200
Re: intercept an alert "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2014-05-12 16:19 +0200
Re: intercept an alert Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2014-05-12 19:35 +0200
Re: intercept an alert garrett.smith@acxiom.com - 2014-05-14 09:57 -0700
Re: intercept an alert Dr J R Stockton <reply1400@merlyn.demon.co.uk.invalid> - 2014-05-13 18:00 +0100
Re: intercept an alert garrett.smith@acxiom.com - 2014-05-14 09:57 -0700
csiph-web