<?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: A simple map function for plain JavaScript arrays</title>
	<atom:link href="http://www.lazycoder.com/weblog/2009/08/12/a-simple-map-function-for-plain-javascript-arrays/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.lazycoder.com/weblog/2009/08/12/a-simple-map-function-for-plain-javascript-arrays/</link>
	<description></description>
	<lastBuildDate>Fri, 07 Oct 2011 15:08:00 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
	<item>
		<title>By: thomd</title>
		<link>http://www.lazycoder.com/weblog/2009/08/12/a-simple-map-function-for-plain-javascript-arrays/comment-page-1/#comment-210837</link>
		<dc:creator>thomd</dc:creator>
		<pubDate>Sun, 05 Dec 2010 23:14:28 +0000</pubDate>
		<guid isPermaLink="false">http://www.lazycoder.com/weblog/2009/08/12/a-simple-map-function-for-plain-javascript-arrays/#comment-210837</guid>
		<description>what about:

Array.prototype.map = function(fn) {
  for (i = this.length; this[i] = fn(this[i--]); );
  return this;
};</description>
		<content:encoded><![CDATA[<p>what about:</p>
<p>Array.prototype.map = function(fn) {<br />
  for (i = this.length; this[i] = fn(this[i--]); );<br />
  return this;<br />
};</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: jesus</title>
		<link>http://www.lazycoder.com/weblog/2009/08/12/a-simple-map-function-for-plain-javascript-arrays/comment-page-1/#comment-208624</link>
		<dc:creator>jesus</dc:creator>
		<pubDate>Wed, 03 Nov 2010 13:56:35 +0000</pubDate>
		<guid isPermaLink="false">http://www.lazycoder.com/weblog/2009/08/12/a-simple-map-function-for-plain-javascript-arrays/#comment-208624</guid>
		<description>it would be best if you did r = new Array(l)</description>
		<content:encoded><![CDATA[<p>it would be best if you did r = new Array(l)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: argimenes</title>
		<link>http://www.lazycoder.com/weblog/2009/08/12/a-simple-map-function-for-plain-javascript-arrays/comment-page-1/#comment-206157</link>
		<dc:creator>argimenes</dc:creator>
		<pubDate>Sun, 05 Sep 2010 23:29:49 +0000</pubDate>
		<guid isPermaLink="false">http://www.lazycoder.com/weblog/2009/08/12/a-simple-map-function-for-plain-javascript-arrays/#comment-206157</guid>
		<description>Nice article... with respect to concise syntax, you could try:

Array.prototype.map = function(fn) {
  for (i=0, r=[], l = this.length; i &lt; l; r.push(fn(this[i++])));
  return r;
};</description>
		<content:encoded><![CDATA[<p>Nice article&#8230; with respect to concise syntax, you could try:</p>
<p>Array.prototype.map = function(fn) {<br />
  for (i=0, r=[], l = this.length; i &lt; l; r.push(fn(this[i++])));<br />
  return r;<br />
};</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: A simple map function for plain JavaScript arrays &#124; Lazycoder</title>
		<link>http://www.lazycoder.com/weblog/2009/08/12/a-simple-map-function-for-plain-javascript-arrays/comment-page-1/#comment-194700</link>
		<dc:creator>A simple map function for plain JavaScript arrays &#124; Lazycoder</dc:creator>
		<pubDate>Thu, 13 Aug 2009 19:39:43 +0000</pubDate>
		<guid isPermaLink="false">http://www.lazycoder.com/weblog/2009/08/12/a-simple-map-function-for-plain-javascript-arrays/#comment-194700</guid>
		<description>[...] the rest here: A simple map function for plain JavaScript arrays &#124; Lazycoder   SHARETHIS.addEntry({ title: &quot;A simple map function for plain JavaScript arrays &#124; Lazycoder&quot;, url: [...]</description>
		<content:encoded><![CDATA[<p>[...] the rest here: A simple map function for plain JavaScript arrays | Lazycoder   SHARETHIS.addEntry({ title: &quot;A simple map function for plain JavaScript arrays | Lazycoder&quot;, url: [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: JavaScript: Not for the faint at heart? &#124; Lazycoder</title>
		<link>http://www.lazycoder.com/weblog/2009/08/12/a-simple-map-function-for-plain-javascript-arrays/comment-page-1/#comment-194695</link>
		<dc:creator>JavaScript: Not for the faint at heart? &#124; Lazycoder</dc:creator>
		<pubDate>Thu, 13 Aug 2009 16:22:39 +0000</pubDate>
		<guid isPermaLink="false">http://www.lazycoder.com/weblog/2009/08/12/a-simple-map-function-for-plain-javascript-arrays/#comment-194695</guid>
		<description>[...] &#8220;var foo = new Foo();&#8221;. But when you see how trvial it is to implement something like a map method in JavaScript, you realize how powerful the language can be. Most of the hatred for JavaScript comes from two [...]</description>
		<content:encoded><![CDATA[<p>[...] &#8220;var foo = new Foo();&#8221;. But when you see how trvial it is to implement something like a map method in JavaScript, you realize how powerful the language can be. Most of the hatred for JavaScript comes from two [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Dew Drop &#8211; August 13, 2009 &#124; Alvin Ashcraft's Morning Dew</title>
		<link>http://www.lazycoder.com/weblog/2009/08/12/a-simple-map-function-for-plain-javascript-arrays/comment-page-1/#comment-194691</link>
		<dc:creator>Dew Drop &#8211; August 13, 2009 &#124; Alvin Ashcraft's Morning Dew</dc:creator>
		<pubDate>Thu, 13 Aug 2009 12:44:48 +0000</pubDate>
		<guid isPermaLink="false">http://www.lazycoder.com/weblog/2009/08/12/a-simple-map-function-for-plain-javascript-arrays/#comment-194691</guid>
		<description>[...] A simple map function for plain JavaScript arrays (Scott Koon) [...]</description>
		<content:encoded><![CDATA[<p>[...] A simple map function for plain JavaScript arrays (Scott Koon) [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Daily Links for Thursday, August 13th, 2009</title>
		<link>http://www.lazycoder.com/weblog/2009/08/12/a-simple-map-function-for-plain-javascript-arrays/comment-page-1/#comment-194689</link>
		<dc:creator>Daily Links for Thursday, August 13th, 2009</dc:creator>
		<pubDate>Thu, 13 Aug 2009 11:32:24 +0000</pubDate>
		<guid isPermaLink="false">http://www.lazycoder.com/weblog/2009/08/12/a-simple-map-function-for-plain-javascript-arrays/#comment-194689</guid>
		<description>[...] A simple map function for plain JavaScript arrays &#124; Lazycoder [...]</description>
		<content:encoded><![CDATA[<p>[...] A simple map function for plain JavaScript arrays | Lazycoder [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Scott</title>
		<link>http://www.lazycoder.com/weblog/2009/08/12/a-simple-map-function-for-plain-javascript-arrays/comment-page-1/#comment-194680</link>
		<dc:creator>Scott</dc:creator>
		<pubDate>Thu, 13 Aug 2009 03:23:29 +0000</pubDate>
		<guid isPermaLink="false">http://www.lazycoder.com/weblog/2009/08/12/a-simple-map-function-for-plain-javascript-arrays/#comment-194680</guid>
		<description>Duncan: with a for-in loop and a JavaScript array, you end up looping over all members of the Array type. If you have modified the prototype of the native Array, you&#039;ll end up iterating over them as well. See this post for a better explanation as well as a way to avoid that.

http://www.lazycoder.com/weblog/2008/05/23/modern-javascript-development-reflection-in-javascrpt/


edit: Ok, that post I linked to helps if you are dealing with objects that are not native JavaScript objects. Native JavaScript objects are a little bit different. The members of native JavaScript objects are marked as non-enumerable, so for-in works on them provided that their prototype object  has not been modified. If it has, you&#039;ll have to use a combination of the technique described in the post aboce as well as special casing out the members you know have been added to the native JavaScript object.</description>
		<content:encoded><![CDATA[<p>Duncan: with a for-in loop and a JavaScript array, you end up looping over all members of the Array type. If you have modified the prototype of the native Array, you&#8217;ll end up iterating over them as well. See this post for a better explanation as well as a way to avoid that.</p>
<p><a href="http://www.lazycoder.com/weblog/2008/05/23/modern-javascript-development-reflection-in-javascrpt/" rel="nofollow">http://www.lazycoder.com/weblog/2008/05/23/modern-javascript-development-reflection-in-javascrpt/</a></p>
<p>edit: Ok, that post I linked to helps if you are dealing with objects that are not native JavaScript objects. Native JavaScript objects are a little bit different. The members of native JavaScript objects are marked as non-enumerable, so for-in works on them provided that their prototype object  has not been modified. If it has, you&#8217;ll have to use a combination of the technique described in the post aboce as well as special casing out the members you know have been added to the native JavaScript object.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Nate Kohari</title>
		<link>http://www.lazycoder.com/weblog/2009/08/12/a-simple-map-function-for-plain-javascript-arrays/comment-page-1/#comment-194676</link>
		<dc:creator>Nate Kohari</dc:creator>
		<pubDate>Wed, 12 Aug 2009 23:44:36 +0000</pubDate>
		<guid isPermaLink="false">http://www.lazycoder.com/weblog/2009/08/12/a-simple-map-function-for-plain-javascript-arrays/#comment-194676</guid>
		<description>Very useful. (I have a similar implementation myself.) By the way, I&#039;ve used this sort of syntax for loops:

for (int idx = 0, len = arr.length; idx++; idx &lt; len) {
  ...
}</description>
		<content:encoded><![CDATA[<p>Very useful. (I have a similar implementation myself.) By the way, I&#8217;ve used this sort of syntax for loops:</p>
<p>for (int idx = 0, len = arr.length; idx++; idx &lt; len) {<br />
  &#8230;<br />
}</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Duncan Smart</title>
		<link>http://www.lazycoder.com/weblog/2009/08/12/a-simple-map-function-for-plain-javascript-arrays/comment-page-1/#comment-194675</link>
		<dc:creator>Duncan Smart</dc:creator>
		<pubDate>Wed, 12 Aug 2009 21:35:48 +0000</pubDate>
		<guid isPermaLink="false">http://www.lazycoder.com/weblog/2009/08/12/a-simple-map-function-for-plain-javascript-arrays/#comment-194675</guid>
		<description>What about sparse arrays? (ok, maybe they&#039;re rare on the wild) How about for ... in to loop through?</description>
		<content:encoded><![CDATA[<p>What about sparse arrays? (ok, maybe they&#8217;re rare on the wild) How about for &#8230; in to loop through?</p>
]]></content:encoded>
	</item>
</channel>
</rss>

