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


Groups > comp.lang.javascript > #18036

Re: Request for opinions on my newbie approach

Path csiph.com!newsfeed.hal-mli.net!feeder3.hal-mli.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!feeder.erje.net!eu.feeder.erje.net!zen.net.uk!dedekind.zen.co.uk!aioe.org!.POSTED!not-for-mail
From Cezary Tomczyk <cezary.tomczyk@gmail.com>
Newsgroups comp.lang.javascript
Subject Re: Request for opinions on my newbie approach
Date Wed, 09 Jan 2013 20:41:47 +0100
Organization Aioe.org NNTP Server
Lines 29
Message-ID <kckh5m$d5l$1@speranza.aioe.org> (permalink)
References <kcilrc$vt8$1@dont-email.me> <10136443.OnBuAidq6I@PointedEars.de> <a2hre85m1aojpu1l2a46uqbklvnhq7ih3h@4ax.com>
NNTP-Posting-Host zYd0PXwpR9QMvAmoEDGsiw.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:17.0) Gecko/20130107 Thunderbird/17.0.2
X-Notice Filtered by postfilter v. 0.8.2
Xref csiph.com comp.lang.javascript:18036

Show key headers only | View raw


W dniu 2013-01-09 20:32, Jim T. pisze:
> On Wed, 09 Jan 2013 04:31:58 +0100, Thomas 'PointedEars' Lahn
> <PointedEars@web.de> wrote:
>
>> Leonardo Azpurua wrote:
[...]
>>>      for (var i = 0; i < f.elements.length; i++)
>>
>>       for (var i = 0, len = f.elements.length; i < len; ++i)
>
> Why? Because it's faster? First, modern JS interpreters will probably
> already do this optimization. Second, unless the form has a million
> elements it will make no noticeable difference. Cleaner code is better
> than pointless "optimization".

I wonder: what is not clean in this code?

for (var i = 0, len = f.elements.length; i < len; ++i)

Maybe you can write it as (as you want):

for (var i = 0, len = f.elements.length; i < len; i += 1)

Still can not see what can be confused here for developer. It's just a 
simple, one line begin of loop.

-- 
Cezary Tomczyk
http://www.ctomczyk.pl/

Back to comp.lang.javascript | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

Request for opinions on my newbie approach "Leonardo Azpurua" <leonardo@exmvps.org> - 2013-01-08 22:24 -0430
  Re: Request for opinions on my newbie approach Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2013-01-09 04:31 +0100
    Re: Request for opinions on my newbie approach "Leonardo Azpurua" <leonardo@exmvps.org> - 2013-01-08 23:34 -0430
      Re: Request for opinions on my newbie approach Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2013-01-09 05:14 +0100
    Re: Request for opinions on my newbie approach Jim T. <x@y.z> - 2013-01-09 14:32 -0500
      Re: Request for opinions on my newbie approach Cezary Tomczyk <cezary.tomczyk@gmail.com> - 2013-01-09 20:41 +0100
        Re: Request for opinions on my newbie approach Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2013-01-09 21:03 +0100
        Re: Request for opinions on my newbie approach Jim T. <x@y.z> - 2013-01-09 15:11 -0500
        Re: Request for opinions on my newbie approach Luc Yen <luc@goal.tw> - 2013-01-09 14:38 -0800
      Re: Request for opinions on my newbie approach "Leonardo Azpurua" <leonardo@exmvps.org> - 2013-01-09 18:10 -0430
        Re: Request for opinions on my newbie approach Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2013-01-10 01:36 +0100

csiph-web