Path: csiph.com!usenet.pasdenom.info!dedibox.gegeweb.org!gegeweb.eu!nntpfeed.proxad.net!proxad.net!feeder2-2.proxad.net!newsfeed.arcor.de!newsspool4.arcor-online.net!news.arcor.de.POSTED!not-for-mail Content-Type: text/plain; charset="ISO-8859-1" Message-ID: <1973704.ddpYkadBz4@PointedEars.de> From: Thomas 'PointedEars' Lahn Reply-To: Thomas 'PointedEars' Lahn Organization: PointedEars Software (PES) Date: Wed, 28 Aug 2013 02:08:52 +0200 User-Agent: KNode/4.10.5 Content-Transfer-Encoding: 7Bit X-Face: %i>XG-yXR'\"2P/C_aO%~;2o~?g0pPKmbOw^=NT`tprDEf++D.m7"}HW6.#=U:?2GGctkL,f89@H46O$ASoW&?s}.k+&. <2725916.yAnYnyUf7L@PointedEars.de> MIME-Version: 1.0 Lines: 80 NNTP-Posting-Date: 28 Aug 2013 02:08:54 CEST NNTP-Posting-Host: b58e0fad.newsspool1.arcor-online.net X-Trace: DXC=_d:9:?e8T4QAX0F2i> On 27.08.2013 16:02, Thomas 'PointedEars' Lahn wrote: >> That is awful code style for array iteration, in probably every language >> of the C family. Consider this instead: > > Oh, this is not C, ECMAScript implementations rather clearly belong to the C *family* of programming languages as opposed to, for example, Python. > this is ECMAScript in the JavaScript flavor, No, it is any ECMAScript implementation, depending on the runtime environment in which it is executed. See also pp. > a dynamic language. Nothing is compiled, everything is interpreted. No, that is a common misconception. Source code for ECMAScript implementations is either JIT-compiled to bytecode that is executed by a Virtual Machine, or it is compiled to platform-native machine code. There is a tendency now to JIT-compile to platform-native machine code, as can be seen with Apple/WebKit JavaScriptCore SquirrelFish Extreme and Google V8 JavaScript. > If you understand how interpreting works you would know this doesn't > really matter (and in this case the bottleneck is not the loop). YMMD. >> It makes more sense to append the object reference to the Array *after* >> the object is prepared: > > Doesn't matter at all in this case. Yes, it does. > The Image element is a valid reference before src is set and image loading > is an asynchrounous operation in JavaScript. Image loading is not even part of JavaScript (or ECMAScript), it is a DOM feature. You must have been asleep for the last decade or so. > If its reference is kept in an array, object or as a variable does not > matter at all as long as it is referenced. > > Look at Image element as parent of data, not part of it. I am referring to how easy source code can be read and understood by a *person*. It is harder to understand if it is written your way. This matters of the target audience is a (one) beginner. >> It is even questionable to have the Image instance references in an >> Array, as then there is no random access to them, for example by name or >> ID. > > I think you are forgetting that you can use the URL to identify which > image has loaded if you need to reference its index. I think you do not understand how Arrays are working in ECMAScript, and what image preloading is used for in DOM scripting. I also think you should refresh your knowledge on hash tables, which are likely used internally for property lookup (as opposed to linear array search). >> In your code you declare 3 global properties that should be avoided by >> using namespacing (for lack of a better word): > > You are missing the point here. I am not providing a full working > solution but an example. It's up to OP to modify and adopt to suit his > needs. Bad examples are *bad* examples. You should post good examples, especially as followup to beginners. -- PointedEars Twitter: @PointedEars2 Please do not Cc: me. / Bitte keine Kopien per E-Mail.