<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: My New Favorite Loop</title>
	<atom:link href="http://www.digitalmediaminute.com/article/2098/my-new-favorite-loop/feed" rel="self" type="application/rss+xml" />
	<link>http://www.digitalmediaminute.com/article/2098/my-new-favorite-loop</link>
	<description>News that matters for Web Developers</description>
	<lastBuildDate>Sat, 04 Feb 2012 20:26:44 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
	<item>
		<title>By: mike</title>
		<link>http://www.digitalmediaminute.com/article/2098/my-new-favorite-loop/comment-page-1#comment-9745</link>
		<dc:creator>mike</dc:creator>
		<pubDate>Thu, 06 Jul 2006 15:35:07 +0000</pubDate>
		<guid isPermaLink="false">http://www.digitalmediaminute.com/article/2098/my-new-favorite-loop#comment-9745</guid>
		<description>That&#039;s brilliant. Thank you.</description>
		<content:encoded><![CDATA[<p>That&#8217;s brilliant. Thank you.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Michel</title>
		<link>http://www.digitalmediaminute.com/article/2098/my-new-favorite-loop/comment-page-1#comment-3485</link>
		<dc:creator>Michel</dc:creator>
		<pubDate>Wed, 12 Apr 2006 12:38:06 +0000</pubDate>
		<guid isPermaLink="false">http://www.digitalmediaminute.com/article/2098/my-new-favorite-loop#comment-3485</guid>
		<description>Similarly, a while loop can be useful when iterating over a collection of elements:
var images = document.getElementsByTagName(&#039;img&#039;), i = 0;
while (img = images[i++]) {
  //
}</description>
		<content:encoded><![CDATA[<p>Similarly, a while loop can be useful when iterating over a collection of elements:<br />
var images = document.getElementsByTagName(&#8216;img&#8217;), i = 0;<br />
while (img = images[i++]) {<br />
  //<br />
}</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: John</title>
		<link>http://www.digitalmediaminute.com/article/2098/my-new-favorite-loop/comment-page-1#comment-3464</link>
		<dc:creator>John</dc:creator>
		<pubDate>Tue, 11 Apr 2006 00:47:04 +0000</pubDate>
		<guid isPermaLink="false">http://www.digitalmediaminute.com/article/2098/my-new-favorite-loop#comment-3464</guid>
		<description>I don&#039;t recommend this method at all. It would require extra documentation to alert programmers to what you&#039;re doing and with all the aforementioned problems, it appears as little more than a cute hack.</description>
		<content:encoded><![CDATA[<p>I don&#8217;t recommend this method at all. It would require extra documentation to alert programmers to what you&#8217;re doing and with all the aforementioned problems, it appears as little more than a cute hack.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Danilo</title>
		<link>http://www.digitalmediaminute.com/article/2098/my-new-favorite-loop/comment-page-1#comment-3462</link>
		<dc:creator>Danilo</dc:creator>
		<pubDate>Mon, 10 Apr 2006 16:45:27 +0000</pubDate>
		<guid isPermaLink="false">http://www.digitalmediaminute.com/article/2098/my-new-favorite-loop#comment-3462</guid>
		<description>Jonathan,

Unless the actions within the loop make modifications to the array (that is add or remove elements) then it is a good idea to store the array length in a variable and use that variable to to constrain the looping.</description>
		<content:encoded><![CDATA[<p>Jonathan,</p>
<p>Unless the actions within the loop make modifications to the array (that is add or remove elements) then it is a good idea to store the array length in a variable and use that variable to to constrain the looping.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jonathan</title>
		<link>http://www.digitalmediaminute.com/article/2098/my-new-favorite-loop/comment-page-1#comment-3390</link>
		<dc:creator>Jonathan</dc:creator>
		<pubDate>Wed, 05 Apr 2006 02:40:59 +0000</pubDate>
		<guid isPermaLink="false">http://www.digitalmediaminute.com/article/2098/my-new-favorite-loop#comment-3390</guid>
		<description>Hmm. My comment was cut off, it seems. My question was whether it were better to use the form for (var i=0, len=myArray.length; i </description>
		<content:encoded><![CDATA[<p>Hmm. My comment was cut off, it seems. My question was whether it were better to use the form for (var i=0, len=myArray.length; i</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jonathan</title>
		<link>http://www.digitalmediaminute.com/article/2098/my-new-favorite-loop/comment-page-1#comment-3389</link>
		<dc:creator>Jonathan</dc:creator>
		<pubDate>Wed, 05 Apr 2006 02:37:45 +0000</pubDate>
		<guid isPermaLink="false">http://www.digitalmediaminute.com/article/2098/my-new-favorite-loop#comment-3389</guid>
		<description>Given all that, is it still better to evaluate the array&#039;s length only once, as in the mentioned alternative?:

for (var a=0, len=someArray.length; a</description>
		<content:encoded><![CDATA[<p>Given all that, is it still better to evaluate the array&#8217;s length only once, as in the mentioned alternative?:</p>
<p>for (var a=0, len=someArray.length; a</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Nelson Winters</title>
		<link>http://www.digitalmediaminute.com/article/2098/my-new-favorite-loop/comment-page-1#comment-3340</link>
		<dc:creator>Nelson Winters</dc:creator>
		<pubDate>Thu, 30 Mar 2006 15:47:12 +0000</pubDate>
		<guid isPermaLink="false">http://www.digitalmediaminute.com/article/2098/my-new-favorite-loop#comment-3340</guid>
		<description>Using a for/in loop can help with keeping things simple:

var aryTest = new Array(&quot;Red&quot;, &quot;Green&quot;, &quot;Blue&quot;);
for (var i in aryTest) {
    alert(i + &quot;: &quot; + aryTest[i]);
}</description>
		<content:encoded><![CDATA[<p>Using a for/in loop can help with keeping things simple:</p>
<p>var aryTest = new Array(&#8220;Red&#8221;, &#8220;Green&#8221;, &#8220;Blue&#8221;);<br />
for (var i in aryTest) {<br />
    alert(i + &#8220;: &#8221; + aryTest[i]);<br />
}</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Danilo</title>
		<link>http://www.digitalmediaminute.com/article/2098/my-new-favorite-loop/comment-page-1#comment-3339</link>
		<dc:creator>Danilo</dc:creator>
		<pubDate>Thu, 30 Mar 2006 15:07:28 +0000</pubDate>
		<guid isPermaLink="false">http://www.digitalmediaminute.com/article/2098/my-new-favorite-loop#comment-3339</guid>
		<description>This will loop also ends if you have an empty string as one of the member, or if you have an array of objects and one of the objects is undefined or null.

So to sumarize my understanding of the times you don&#039;t want to use this type of looping is:
1. When there is the possiblity of a missing element within the array.
2. When you&#039;re using numbers, as 0 will end the loop.
3. When you have boolean values as false will end the loop
4. When you&#039;re using strings, as an empty string will end the loop.
5. When you&#039;re using objects, as null or undefined object values will end the loop.

Given the above limitations, and on your statement that  that improvements don&#039;t appear until your go over 1000 items in the array, it seems to me that the very real potential of your code breaking by using this style of loop is simply not worth the a few processing cycles.

For the special case that you can actually use this type of loop with confidence, I suggest commenting your code  profusely, including mentioning that it is subject to breaking under the above circumstances, so that when your array changes down the road, hopefully you will see that using this loop is what broke things.</description>
		<content:encoded><![CDATA[<p>This will loop also ends if you have an empty string as one of the member, or if you have an array of objects and one of the objects is undefined or null.</p>
<p>So to sumarize my understanding of the times you don&#8217;t want to use this type of looping is:<br />
1. When there is the possiblity of a missing element within the array.<br />
2. When you&#8217;re using numbers, as 0 will end the loop.<br />
3. When you have boolean values as false will end the loop<br />
4. When you&#8217;re using strings, as an empty string will end the loop.<br />
5. When you&#8217;re using objects, as null or undefined object values will end the loop.</p>
<p>Given the above limitations, and on your statement that  that improvements don&#8217;t appear until your go over 1000 items in the array, it seems to me that the very real potential of your code breaking by using this style of loop is simply not worth the a few processing cycles.</p>
<p>For the special case that you can actually use this type of loop with confidence, I suggest commenting your code  profusely, including mentioning that it is subject to breaking under the above circumstances, so that when your array changes down the road, hopefully you will see that using this loop is what broke things.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: barry.b</title>
		<link>http://www.digitalmediaminute.com/article/2098/my-new-favorite-loop/comment-page-1#comment-3333</link>
		<dc:creator>barry.b</dc:creator>
		<pubDate>Thu, 30 Mar 2006 06:24:56 +0000</pubDate>
		<guid isPermaLink="false">http://www.digitalmediaminute.com/article/2098/my-new-favorite-loop#comment-3333</guid>
		<description>sorry to sound like a dumb-ass but I don&#039;t get it.

does the o=someArray[a] part resolve to &quot;false&quot; if the [a+1] element doesn&#039;t exist? and that&#039;s how it finishes?</description>
		<content:encoded><![CDATA[<p>sorry to sound like a dumb-ass but I don&#8217;t get it.</p>
<p>does the o=someArray[a] part resolve to &#8220;false&#8221; if the [a+1] element doesn&#8217;t exist? and that&#8217;s how it finishes?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jim</title>
		<link>http://www.digitalmediaminute.com/article/2098/my-new-favorite-loop/comment-page-1#comment-3332</link>
		<dc:creator>Jim</dc:creator>
		<pubDate>Thu, 30 Mar 2006 06:05:48 +0000</pubDate>
		<guid isPermaLink="false">http://www.digitalmediaminute.com/article/2098/my-new-favorite-loop#comment-3332</guid>
		<description>I did my speed test in Firefox 1.5 PC.  I will post my script tomorrow along with a table documenting those speeds.</description>
		<content:encoded><![CDATA[<p>I did my speed test in Firefox 1.5 PC.  I will post my script tomorrow along with a table documenting those speeds.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jonathan Snook</title>
		<link>http://www.digitalmediaminute.com/article/2098/my-new-favorite-loop/comment-page-1#comment-3331</link>
		<dc:creator>Jonathan Snook</dc:creator>
		<pubDate>Thu, 30 Mar 2006 05:53:49 +0000</pubDate>
		<guid isPermaLink="false">http://www.digitalmediaminute.com/article/2098/my-new-favorite-loop#comment-3331</guid>
		<description>Which browsers did you do your speed tests in? it&#039;d be interested to see a comparison chart of the 3 methods in each of the major browsers (FF, IE, Safari)</description>
		<content:encoded><![CDATA[<p>Which browsers did you do your speed tests in? it&#8217;d be interested to see a comparison chart of the 3 methods in each of the major browsers (FF, IE, Safari)</p>
]]></content:encoded>
	</item>
</channel>
</rss>

