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 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> References: <2221038.iVyETpmlb9@PointedEars.de> Reply-To: Thomas 'PointedEars' Lahn 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/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== X-Face: %i>XG-yXR'\"2P/C_aO%~;2o~?g0pPKmbOw^=NT`tprDEf++D.m7"}HW6.#=U:?2GGctkL,f89@H46O$ASoW&?s}.k+&. 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, > > 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: | SVN: Twitter: @PointedEars2 | ES Matrix: Please do not Cc: me. / Bitte keine Kopien per E-Mail.