Path: csiph.com!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!ecngs!feeder2.ecngs.de!217.188.199.168.MISMATCH!takemy.news.telefonica.de!telefonica.de!newsfeed.arcor.de!newsspool4.arcor-online.net!news.arcor.de.POSTED!not-for-mail Content-Type: text/plain; charset="UTF-8" Message-ID: <6778903.525aRzo9tQ@PointedEars.de> From: Thomas 'PointedEars' Lahn Reply-To: Thomas 'PointedEars' Lahn Organization: PointedEars Software (PES) Date: Wed, 12 Mar 2014 01:27:43 +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+&. <868d8999-f1b7-49bb-a33c-4e76b00ecafa@googlegroups.com> <253eca00-abda-47da-8388-8a621f36fffd@googlegroups.com> <59661127-bbd4-4eb5-b824-1b4074ccfbd9@googlegroups.com> <531f548b$0$6672$9b4e6d93@newsspool2.arcor-online.net> <531fa123$0$6667$9b4e6d93@newsspool2.arcor-online.net> MIME-Version: 1.0 Lines: 82 NNTP-Posting-Date: 12 Mar 2014 01:27:45 CET NNTP-Posting-Host: 0418426a.newsspool1.arcor-online.net X-Trace: DXC=1PSI?oEic==]BZ:afN4Fo<]lROoRAnkgeX?EC@@@KPeR?^YhTLGDZm8W4\YJNLYUVHKH;GI^G<_e=dZX jonas.thornvall@gmail.com wrote: >> I try to get the gist of what you saying but for me it is all very >> confusing. Do you mean something like this? >> >> var arr = new Array(); >> for (var i = -500; i <= +500; i ++ ) >> { >> arr[i] = >> { >> count : i, >> fcolor : 'black', >> rheight : 100, >> rwidth : 100, >> rcolor : 'white' >> } >> } > > Yes. If you prefer, you can use another variable to store the object > first, e.g.: > > { > var obj = {...}; > arr[i] = obj; > } It is not possible to store objects in variables/properties. It is only possible to store *references to* objects. References are values. The difference is important because it emphasizes that there can be several references to the same object, and there can be unnamed references. [0] In short: Objects have identity, not name. The above Block statement is equivalent to var obj; { obj = {...}; arr[i] = obj; } which means: 1. Declare a (here: local) variable named “obj”. (This happens *before* control enters the Block statement, even before all other statements in that local context are executed.) [1] 2. Create an Object instance, initialize it with the specified properties, and return a reference to it (“return” with regard to the algorithm only; understood as the *evaluation value*). [2] 3. Assign to “obj” the reference to the newly created object. [3] 4. Retrieve the reference to the newly created object from “obj” [4] and store it in (copy it to) the property of the object referred to by “arr” that is specified by the value of “i” converted to String. (Create the property if it does not exist and their are no provisions to creating it. [5] If “arr” is referring to an Array instance, modify the value of its “length” property value if the value of “i” is an index value and the value of “i” converted to String, then converted to unsigned 32-bit integer, is greater than the last index in the array. [6]) 5. Set the evaluation value of the Block statement to “obj” because it is the evaluation value of the assignment, which is the last statement in the Block. [7] _______ [0] [1] [2] [3] [4] [5] [6] [7] -- PointedEars FAQ: | SVN: Twitter: @PointedEars2 | ES Matrix: Please do not Cc: me. / Bitte keine Kopien per E-Mail.