Path: csiph.com!usenet.pasdenom.info!aioe.org!.POSTED!not-for-mail From: Joao Rodrigues Newsgroups: comp.lang.javascript Subject: Re: arr.push(obj); Date: Tue, 11 Mar 2014 06:24:27 -0300 Organization: Aioe.org NNTP Server Lines: 29 Message-ID: References: NNTP-Posting-Host: 6sCmKtmp0rL2AxgNAaWk1Q.user.speranza.aioe.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Complaints-To: abuse@aioe.org User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:24.0) Gecko/20100101 Thunderbird/24.3.0 X-Notice: Filtered by postfilter v. 0.8.2 Xref: csiph.com comp.lang.javascript:23515 On 10/03/2014 21:38, jonas.thornvall@gmail.com wrote: > 1. Can javascript have negative index of array[-500]? The first element of an array is at index 0, and the last element is at the index equal to the value of the array's length property minus 1. See: > 2. If so how can i change code below to create object range from -500 > to 500 as i understand it the code will will create an array with > object 0-999. > > for (var i = -500; i <= +500; i ++ ) { var obj = { count : i, fcolor > : 'black', rheight : 100, rwidth : 100, rcolor : 'white' } > > arr.push(obj); } > > 3. If i want to create an object on the fly as a counter > increment/decrement in the code. > > Let us say obj for arr[-501] how go in todo that. > > JT I didn't see an array with negative indices in the code above. -- Joao Rodrigues