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


Groups > comp.lang.javascript > #25488

Re: Images and pdf in a div

Path csiph.com!usenet.pasdenom.info!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: Images and pdf in a div
Date Mon, 21 Jul 2014 02:00:33 +0200
Organization PointedEars Software (PES)
Lines 67
Message-ID <3966722.Cq8BDrRF97@PointedEars.de> (permalink)
References <lqc77u$ljp$1@dont-email.me> <lqdl2u$45o$1@solani.org> <lqds4k$iad$1@dont-email.me> <XnsA36FA164733A9eejj99@194.109.133.133> <lqe6fa$sid$1@dont-email.me> <m_CdnTCZ5NKWzlbOnZ2dnUVZ_tGdnZ2d@westnet.com.au> <2221038.iVyETpmlb9@PointedEars.de> <Zf2dnfu0HYh7olHOnZ2dnUVZ_gqdnZ2d@westnet.com.au>
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 1405900914 15357 eJwFwYEBwDAEBMCVSniMIx/2H6F3fiBgGBzm6/sdFpIUTDLUSrG8MjTJvmvalqLTUXzPM38bcxE9 (21 Jul 2014 00:01:54 GMT)
X-Complaints-To abuse@news.solani.org
NNTP-Posting-Date Mon, 21 Jul 2014 00:01:54 +0000 (UTC)
User-Agent KNode/4.12.4
X-User-ID eJwFwYEBACAEBMCViH8aR8n+I3QHo/KGE3QMRqW2sZf79LPClTaBcpDjFiMrSPVHVlWGsXK3nXvyETH5ATxLFQ8=
Face iVBORw0KGgoAAAANSUhEUgAAADAAAAAwBAMAAAClLOS0AAAAGFBMVEXTxa4RFk5dUWANED8PFEfy7+MGBiW+n3ZNF/QuAAACaElEQVQ4jVXUwVOcMBQG8Dc7Rc4PUntdWV2uxjDpGaGeozOp1woar4jd5t/v9wLstMws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809i8Zoq6m/PIWSa6CMiIIPrJDJabxIux8OahBf
Xref csiph.com comp.lang.javascript:25488

Show key headers only | View raw


Andrew Poulos wrote:

> On 20/07/2014 8:42 PM, Thomas 'PointedEars' Lahn wrote:
>> Andrew Poulos wrote:
>>>     var isInstalled = false,
>>>         vern = null;
>>>
>>>     function findPlugin(nme) {
>>>       var p;
>>>       for (key in navigator.plugins) {
>>
>> Do not use the for-in statement with host objects and array-like objects;
>> their properties may not be enumerable, not in a defined order or have
>> enumerable properties that you do not want to iterate over (like
>> “refresh”);
>> use the “for” statement instead.  Exception: Array instances known to
>> encapsulate a sparse array; in that case for-in is more efficient, and
>> you can filter and sort the properties later, if necessary.
> 
> How do I search through navigator.plugins using "for" instead of "for-in"?

  for (var i = 0, plugins = navigator.plugins, len = plugins.length;
       i < len; ++i)
  {
    … plugins[i] …
  }

(One of the properties you get when you use for-in is the “length” property 
from which you could have inferred that.)
 
>> “isInstalled” is superfluous because you can test against the value of
>> “plugin” instead, which would be either not “null” or not “undefined” if
>> successful, depending on how you initialize it.
> 
> After searching for "plugin" I set it to null to clear any memory...

Unnecessary if you do not return it, may even be harmful.
 
>> And “}())” instead in order to make clear what makes up the right-hand
>> side expression.  This will also become handy in editors like Vim or
>> Eclipse JSDT with Vrapper plugin, where, which I discovered yesterday,
>> you can type “vi)” to select everything between the outer parentheses,
>> for refactoring.
> 
> Ok,
> <http://dmitrysoshnikov.com/ecmascript/chapter-5-functions/#question-about-surrounding-parentheses>
> says that both are correct so I just picked the first one.

Where you put the parantheses in this case is a matter of code style.

However, there are several factually wrong or misleading statements in that 
text.  I find it interesting that someone who has demonstrated here 
(approximately at the time of writing that article, or shortly after) that 
he neither understood ECMAScript nor that he was willing to learn, now 
thinks he can teach others about it.  I find it even more interesting that 
some people believe those statements as if he would be some kind of 
authority on the subject.

> Thanks for the advice.

You’re welcome.

-- 
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 | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Images and pdf in a div danca <cyberdanny@tiscalinet.it> - 2014-07-19 00:31 +0200
  Re: Images and pdf in a div "Christoph M. Becker" <cmbecker69@arcor.de> - 2014-07-19 13:34 +0200
    Re: Images and pdf in a div danca <cyberdanny@tiscalinet.it> - 2014-07-19 15:34 +0200
      Re: Images and pdf in a div "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2014-07-19 15:51 +0200
        Re: Images and pdf in a div danca <cyberdanny@tiscalinet.it> - 2014-07-19 18:30 +0200
          Re: Images and pdf in a div Andrew Poulos <ap_prog@hotmail.com> - 2014-07-20 15:23 +1000
            Re: Images and pdf in a div Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2014-07-20 12:42 +0200
              Re: Images and pdf in a div danca <cyberdanny@tiscalinet.it> - 2014-07-20 20:07 +0200
                Re: Images and pdf in a div Andrew Poulos <ap_prog@hotmail.com> - 2014-07-21 14:10 +1000
                Re: Images and pdf in a div danca <cyberdanny@tiscalinet.it> - 2014-07-21 14:19 +0200
              Re: Images and pdf in a div Andrew Poulos <ap_prog@hotmail.com> - 2014-07-21 08:14 +1000
                Re: Images and pdf in a div Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2014-07-21 02:00 +0200
                Re: Images and pdf in a div "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2014-07-21 07:15 +0200
                Re: Images and pdf in a div Osmo Saarikumpu <osmo@weppipakki.com> - 2014-07-24 18:26 +0300
                Re: Images and pdf in a div "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2014-07-24 17:48 +0200
                Re: Images and pdf in a div Ben Bacarisse <ben.usenet@bsb.me.uk> - 2014-07-24 22:32 +0100
                Re: Images and pdf in a div "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2014-07-24 23:58 +0200
                Re: Images and pdf in a div "Christoph M. Becker" <cmbecker69@arcor.de> - 2014-07-24 18:40 +0200
                Re: Images and pdf in a div Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2014-07-25 12:31 +0200
                Re: Images and pdf in a div John Harris <niam@jghnorth.org.uk.invalid> - 2014-07-25 15:52 +0100

csiph-web