Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.javascript > #23195
| Path | csiph.com!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!npeer.de.kpn-eurorings.net!npeer-ng0.de.kpn-eurorings.net!newsfeed.arcor.de!newsspool3.arcor-online.net!news.arcor.de.POSTED!not-for-mail |
|---|---|
| Content-Type | text/plain; charset="UTF-8" |
| Message-ID | <6801584.FWXuJcOkgI@PointedEars.de> (permalink) |
| From | Thomas 'PointedEars' Lahn <PointedEars@web.de> |
| Reply-To | Thomas 'PointedEars' Lahn <cljs@PointedEars.de> |
| Organization | PointedEars Software (PES) |
| Date | Sat, 22 Feb 2014 12:50:13 +0100 |
| User-Agent | KNode/4.11.5 |
| Content-Transfer-Encoding | 8Bit |
| X-Face | %i>XG-yXR'\"2P/C_aO%~;2o~?g0pPKmbOw^=NT`tprDEf++D.m7"}HW6.#=U:?2GGctkL,f89@H46O$ASoW&?s}.k+&.<b';Md8`dH6iqhT)6C^.Px|[=M@7=Ik[_w<%n1Up"LPQNu2m8|L!/3iby{-]A+#YE}Kl{Cw$\U!kD%K}\2jz"QQP6Uqr],./"?;=4v |
| Face | iVBORw0KGgoAAAANSUhEUgAAADAAAAAwBAMAAAClLOS0AAAAGFBMVEXTxa4RFk5dUWANED8PFEfy7+MGBiW+n3ZNF/QuAAACaElEQVQ4jVXUwVOcMBQG8Dc7Rc4PUntdWV2uxjDpGaGeozOp1woar4jd5t/v9wLstMwsA/ntlxdCAgUc1hjTc9/JCZfGoo3wG3HdmdAWrIJRHe7GM/TmpY5VFefuVcAkkPbLIaN8rmPmjloyZxgyR3GuJ4K0AGtJ2htz8o7yqikm759fldQXaMpbDzjKAG+8v+AugVTOPO5DOjLvGtUYQwh0CPjnVMyGd+8/GfUB5nLKJDD2aLDh5HYyMDJGDwQIo2ZmZcKbowNmAdB/AzyFhrmF2MHRb0QJJfaAnwGB6orZhoykLzJtGwF/xpYxI1dswomiUj3gTuAIqCn/4C7cULwGNBtwMTk3Y4LfKB5YUaOKBKYtpplm7u0vip8tU1NWWyI/7XdcSuIDoMt6rVHMWT0DbjHPGqDqZVSa6zleLcUTcIKLoMv3ueJluALtAo9B302zPPlrtiVScRdCjXvVh3e3JpYa/jjkuC9N+LrBMlz/eAN4eQijX2EdLo6c5tGGHwLyHFtXk89dDGHwCVhG9T0S/j55AhRZgkMCmUQXJ49TnS1wnQDvw0eAh9ICeMmEFbCnPMFzjAvsWoEWEFdYEx+S0MoUZ1gT1wId8+AF3Bl2OoEu906AUHx5VLw/gXYg/x84loOah/2UYNrgiwSwGO7RfUzVBbx/kgpckumGOi6QirtD6gkLTitbnxNol47S2jVc2vsN5kPqaAHT8uUdAJM4v/DanjYOwmUjWznGfwB7sGtAtor5BgofDuzaRj4kSQAqDakTsKORa3Q3xKi3gE1fhl71KRMqrdZ2AWNNg/YOhQyrVBnb+i+nEg4bsDA+egAAAABJRU5ErkJggg== |
| Subject | Re: How to detect key pressed plus mouse click, e.g., ctrl + left click |
| Newsgroups | comp.lang.javascript |
| References | <pe7fg9dfqg4omh5u888q0vnduas63i47d3@4ax.com> <XnsA2DBCC37E59CCeejj99@194.109.133.133> <tn9fg95v13j6c51bjs89qidr75s5kttk3g@4ax.com> <XnsA2DBD0E11E61Eeejj99@194.109.133.133> <LaidnWADIL12nJXOnZ2dnUVZ_i2dnZ2d@westnet.com.au> <3506285.IpskKQNfjB@PointedEars.de> <XnsA2DC7335FFCD4eejj99@194.109.133.133> <2476103.KEgCaNTNbC@PointedEars.de> <XnsA2DC768E586D7eejj99@194.109.133.133> |
| MIME-Version | 1.0 |
| Lines | 109 |
| NNTP-Posting-Date | 22 Feb 2014 12:50:16 CET |
| NNTP-Posting-Host | b4101a7d.newsspool1.arcor-online.net |
| X-Trace | DXC=_0hWRR1JND4Tia]Ho99G50ic==]BZ:af>4Fo<]lROoR1nkgeX?EC@@0>68l:SlOMR5DZm8W4\YJN<YUVHKH;GI^7>8ZdD_1a;V80];Pa06633; |
| X-Complaints-To | usenet-abuse@arcor.de |
| Xref | csiph.com comp.lang.javascript:23195 |
Show key headers only | View raw
Evertjan. wrote:
> Thomas 'PointedEars' Lahn <PointedEars@web.de> wrote on 22 feb 2014 in
> comp.lang.javascript:
>
>>> e || window.event
>>>
>>> will do fine.
>>>
>>> I [most probably] all applications,
>>> window.event will only be called if e does convert to false.
>>
>> 1. Nothing will be *called* here.
>
> Depending on definition, it will.
You can make up definitions all you want. That does not change the fact
that “window.event” is not a call, but only a property access, by the
definitions in the language specification (and programmer’s common sense).
>> 2. That is beside the point; the *assignment* will take place this way
>> even if not necessary.
>
> Depending on definition, it will not.
Nonsense. The statement
e = e || window.event;
is parsed like
e = (e || window.event);
which reads in pseudo-VM code:
1 BOOLEAN $e
2 NUMBER $1
3 JNZ $2, 6
4 ASSIGN e, $window.event
5 RETURN $window.event
6 ASSIGN e, $e
7 RETURN $e
That is, *regardless* of the values of “e” and “window.event”, the
assignment always takes place. This is unnecessary and error-prone because
assigning the value of “e” to “e” does usually not change the value of “e”.
As compared to
if (!e) e = window.event;
which reads in pseudo-VM code:
1 BOOLEAN $e
2 NUMBER $1
3 JNZ $2, 5
4 RETURN
5 ASSIGN e, $window.event
6 RETURN $window.event
(See the ECMAScript Language Specification, 5.1 Edition, for the elaborate
descriptions.)
>> 3. If a less simple test is necessary
>> (for example, in order to prevent conversion to boolean),
>
> Quod non.
Si tacuisses, philosophus mansisses.
>> the now simple expression will quickly become
>> unreadable, and hard to maintain.
>
> That is beside the point here,
> because this is not about boolean.
Yes, partially it is. If you use the “||” operator, the first operand will
be converted to boolean to see if shortcut evaluation suffices.
The other part is the unnecessary assignment if ”e” already has the proper
value, and error-prone if it refers to a host object (which it does).
We have been over this ad nauseam.
> e || window.event
>
> should be so common that your mind will recognize it at once
> for the near future.
And I presume your mind is too small to store the more efficient, more
flexible, less error-prone
if (!e) e = window.event;
or better
if (typeof e == "undefined")
{
e = window.event;
}
For it is too small to realize the difference between an attribution line
and an attribution novel already. And an e-mail address and something that
only resembles one. And …
--
PointedEars
Twitter: @PointedEars2
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
How to detect key pressed plus mouse click, e.g., ctrl + left click "Joey@still_Learning.invalid" <Joey@still_Learning.invalid> - 2014-02-21 10:45 -0800
Re: How to detect key pressed plus mouse click, e.g., ctrl + left click "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2014-02-21 20:04 +0100
Re: How to detect key pressed plus mouse click, e.g., ctrl + left click "Joey@still_Learning.invalid" <Joey@still_Learning.invalid> - 2014-02-21 11:21 -0800
Re: How to detect key pressed plus mouse click, e.g., ctrl + left click "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2014-02-21 20:32 +0100
Re: How to detect key pressed plus mouse click, e.g., ctrl + left click "Joey@still_Learning.invalid" <Joey@still_Learning.invalid> - 2014-02-21 14:24 -0800
Re: How to detect key pressed plus mouse click, e.g., ctrl + left click "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2014-02-22 00:31 +0100
Re: How to detect key pressed plus mouse click, e.g., ctrl + left click "Joey@still_Learning.invalid" <Joey@still_Learning.invalid> - 2014-02-21 17:41 -0800
Re: How to detect key pressed plus mouse click, e.g., ctrl + left click Andrew Poulos <ap_prog@hotmail.com> - 2014-02-22 12:48 +1100
Re: How to detect key pressed plus mouse click, e.g., ctrl + left click "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2014-02-22 10:36 +0100
Re: How to detect key pressed plus mouse click, e.g., ctrl + left click Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2014-02-22 10:54 +0100
Re: How to detect key pressed plus mouse click, e.g., ctrl + left click "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2014-02-22 11:19 +0100
Re: How to detect key pressed plus mouse click, e.g., ctrl + left click Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2014-02-22 11:27 +0100
Re: How to detect key pressed plus mouse click, e.g., ctrl + left click "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2014-02-22 11:39 +0100
Re: How to detect key pressed plus mouse click, e.g., ctrl + left click Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2014-02-22 12:50 +0100
Re: How to detect key pressed plus mouse click, e.g., ctrl + left click Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2014-02-22 12:56 +0100
Re: How to detect key pressed plus mouse click, e.g., ctrl + left click John Harris <niam@jghnorth.org.uk.invalid> - 2014-02-23 14:00 +0000
Re: How to detect key pressed plus mouse click, e.g., ctrl + left click Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2014-02-23 23:48 +0100
Re: How to detect key pressed plus mouse click, e.g., ctrl + left click Joao Rodrigues <groups_jr-1@yahoo.com.br> - 2014-02-23 20:04 -0300
Re: How to detect key pressed plus mouse click, e.g., ctrl + left click Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2014-02-23 23:39 +0100
csiph-web