<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	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/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>The True Tribe &#187; webkit javascript1.8</title>
	<atom:link href="http://www.thetruetribe.com/tag/webkit-javascript1-8/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.thetruetribe.com</link>
	<description>Vroom! That&#039;s us leaving IE in the dust.</description>
	<lastBuildDate>Fri, 22 Jan 2010 23:34:03 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Javascript 1.8 forEach &#8211; supported in Safari, Firefox and beyond</title>
		<link>http://www.thetruetribe.com/2009/09/javascript-1-8-foreach-supported-in-safari-firefox-and-beyond/</link>
		<comments>http://www.thetruetribe.com/2009/09/javascript-1-8-foreach-supported-in-safari-firefox-and-beyond/#comments</comments>
		<pubDate>Tue, 22 Sep 2009 02:06:05 +0000</pubDate>
		<dc:creator>grandecomplex</dc:creator>
				<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[webkit javascript1.8]]></category>

		<guid isPermaLink="false">http://www.thetruetribe.com/2009/09/javascript-1-8-foreach-supported-in-safari-firefox-and-beyond/</guid>
		<description><![CDATA[If you don&#8217;t have to support IE, you can start taking advantage of JavaScript 1.8 features such as the forEach construct. It&#8217;s nicer than a conventional for loop when you are iterating over every item in an array.
console.log('The Beatles:');
['john','george','ringo','paul'].forEach(function(beatle, i) {
   console.log("name: " + beatle + "\n" + i);
});

// Result:
/*
 * The Beatles:
 [...]]]></description>
			<content:encoded><![CDATA[<p>If you don&#8217;t have to support IE, you can start taking advantage of JavaScript 1.8 features such as the <code>forEach</code> construct. It&#8217;s nicer than a conventional <code>for</code> loop when you are iterating over every item in an array.<span id="more-241"></span></p>
<pre class="js">console.log('The Beatles:');
['john','george','ringo','paul'].forEach(function(beatle, i) {
   console.log("name: " + beatle + "\n" + i);
});

// Result:
/*
 * The Beatles:
 * name: john 0
 * name: george 1
 * name: ringo 2
 * name: paul 3
*/</pre>
<p>This is a great technique when creating iPhone web apps. Since the iPhone sports a modern Webkit browser, we can use <code>forEach.</code></p>
<p>Compare the traditional <code>for</code> with <code>forEach:</code></p>
<pre>// Oldschool way using for
var beatles = ['john','george','ringo','paul'];
for (var i = 0, l = beatles.length; i &lt; l; i++) {
    console.log("name: " + beatles[i] + "\n" + i);
}

// Newschool JavaScript 1.8 forEach
['john','george','ringo','paul'].forEach(function(beatle, i) {
    console.log("name: " + beatle + "\n" + i);
});</pre>
<p>They are functionally the same, but as you can see, the newschool way is much cleaner.</p>
<a class="a2a_dd addtoany_share_save" href="http://www.addtoany.com/share_save?linkurl=http%3A%2F%2Fwww.thetruetribe.com%2F2009%2F09%2Fjavascript-1-8-foreach-supported-in-safari-firefox-and-beyond%2F&amp;linkname=Javascript%201.8%20forEach%20%26%238211%3B%20supported%20in%20Safari%2C%20Firefox%20and%20beyond"><img src="http://www.thetruetribe.com/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share/Bookmark"/></a>]]></content:encoded>
			<wfw:commentRss>http://www.thetruetribe.com/2009/09/javascript-1-8-foreach-supported-in-safari-firefox-and-beyond/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
