<?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: Advanced Javascript: Objects, Arrays, and Array-Like objects</title>
	<atom:link href="http://nfriedly.com/techblog/2009/06/advanced-javascript-objects-arrays-and-array-like-objects/feed/" rel="self" type="application/rss+xml" />
	<link>http://nfriedly.com/techblog/2009/06/advanced-javascript-objects-arrays-and-array-like-objects/</link>
	<description>Expert Advice on Website Development, Javascript, Ajax, and Security</description>
	<lastBuildDate>Wed, 16 May 2012 12:12:25 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
	<item>
		<title>By: 把JavaScript中的伪数组转换为真数组 &#171; 小居</title>
		<link>http://nfriedly.com/techblog/2009/06/advanced-javascript-objects-arrays-and-array-like-objects/comment-page-1/#comment-6408</link>
		<dc:creator>把JavaScript中的伪数组转换为真数组 &#171; 小居</dc:creator>
		<pubDate>Wed, 16 May 2012 12:12:25 +0000</pubDate>
		<guid isPermaLink="false">http://nfriedly.com/techblog/?p=106#comment-6408</guid>
		<description>[...] Advanced Javascript: Objects, Arrays, and Array-Like objects    arguments&#160;array&#160;JavaScript&#160;NodeList&#160;slice    &#8592;短链公关      相关文章 短链公关以用户之名Ubuntu下2个拾色器为gimp添加【保存为web格式】功能Ubuntu之tree命令   随机文章 忘却录音NTLEA区域模拟解决日文游戏乱码问题木头变僵尸，哥字在口边人生若只如初见WordPress固定链接      if (typeof DUOSHUO !== &#039;undefined&#039;) DUOSHUO.EmbedThread(&#039;.ds-thread&#039;);           Copyright &#169; 2012 小居    DUOSHUO.RecentCommentsWidget(&#039;.widget_recent_comments #recentcomments&#039;, {template : &#039;wordpress&#039;});   var _gaq = _gaq &#124;&#124; []; _gaq.push([&#039;_setAccount&#039;, &#039;UA-16074783-2&#039;]); _gaq.push([&#039;_trackPageview&#039;]); (function() { var ga = document.createElement(&#039;script&#039;); ga.type = &#039;text/javascript&#039;; ga.async = true; ga.src = (&#039;https:&#039; == document.location.protocol ? &#039;https://ssl&#039; : &#039;http://www&#039;) + &#039;.google-analytics.com/ga.js&#039;; var s = document.getElementsByTagName(&#039;script&#039;)[0]; s.parentNode.insertBefore(ga, s); })(); [...]</description>
		<content:encoded><![CDATA[<p>[...] Advanced Javascript: Objects, Arrays, and Array-Like objects    arguments&nbsp;array&nbsp;JavaScript&nbsp;NodeList&nbsp;slice    &larr;短链公关      相关文章 短链公关以用户之名Ubuntu下2个拾色器为gimp添加【保存为web格式】功能Ubuntu之tree命令   随机文章 忘却录音NTLEA区域模拟解决日文游戏乱码问题木头变僵尸，哥字在口边人生若只如初见WordPress固定链接      if (typeof DUOSHUO !== &#039;undefined&#039;) DUOSHUO.EmbedThread(&#039;.ds-thread&#039;);           Copyright &copy; 2012 小居    DUOSHUO.RecentCommentsWidget(&#039;.widget_recent_comments #recentcomments&#039;, {template : &#039;wordpress&#039;});   var _gaq = _gaq || []; _gaq.push([&#039;_setAccount&#039;, &#039;UA-16074783-2&#039;]); _gaq.push([&#039;_trackPageview&#039;]); (function() { var ga = document.createElement(&#039;script&#039;); ga.type = &#039;text/javascript&#039;; ga.async = true; ga.src = (&#039;https:&#039; == document.location.protocol ? &#039;<a href="https://ssl&#038;#039">https://ssl&#038;#039</a>; : &#039;<a href="http://www&#038;#039">http://www&#038;#039</a> <img src='http://nfriedly.com/techblog/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' />  + &#039;.google-analytics.com/ga.js&#039;; var s = document.getElementsByTagName(&#039;script&#039;)[0]; s.parentNode.insertBefore(ga, s); })(); [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: nFriedly</title>
		<link>http://nfriedly.com/techblog/2009/06/advanced-javascript-objects-arrays-and-array-like-objects/comment-page-1/#comment-6406</link>
		<dc:creator>nFriedly</dc:creator>
		<pubDate>Mon, 14 May 2012 19:19:04 +0000</pubDate>
		<guid isPermaLink="false">http://nfriedly.com/techblog/?p=106#comment-6406</guid>
		<description>You&#039;re right, the example could be shortened to just that to improve efficiency. I kept it in two parts to make it a little more clear that you&#039;re just working with a regular array after .slice()</description>
		<content:encoded><![CDATA[<p>You&#8217;re right, the example could be shortened to just that to improve efficiency. I kept it in two parts to make it a little more clear that you&#8217;re just working with a regular array after .slice()</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: WMB</title>
		<link>http://nfriedly.com/techblog/2009/06/advanced-javascript-objects-arrays-and-array-like-objects/comment-page-1/#comment-6404</link>
		<dc:creator>WMB</dc:creator>
		<pubDate>Fri, 11 May 2012 01:25:53 +0000</pubDate>
		<guid isPermaLink="false">http://nfriedly.com/techblog/?p=106#comment-6404</guid>
		<description>Hi, 

Your example above slices the argument, returns an array, and then returns a string using join:

---------
var args = Array.prototype.slice.call(arguments);
alert(&quot; your parameters were &quot; + args.join(&quot;, &quot;));
---------

why not just call it directly?

---------
alert( Array.prototype.join.call( arguments )  );
---------

Isnt this more efficient?</description>
		<content:encoded><![CDATA[<p>Hi, </p>
<p>Your example above slices the argument, returns an array, and then returns a string using join:</p>
<p>&#8212;&#8212;&#8212;<br />
var args = Array.prototype.slice.call(arguments);<br />
alert(&#8221; your parameters were &#8221; + args.join(&#8220;, &#8220;));<br />
&#8212;&#8212;&#8212;</p>
<p>why not just call it directly?</p>
<p>&#8212;&#8212;&#8212;<br />
alert( Array.prototype.join.call( arguments )  );<br />
&#8212;&#8212;&#8212;</p>
<p>Isnt this more efficient?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: JavaScript Interview Questions: Arrays &#124; Kevin Chisholm Blog</title>
		<link>http://nfriedly.com/techblog/2009/06/advanced-javascript-objects-arrays-and-array-like-objects/comment-page-1/#comment-5705</link>
		<dc:creator>JavaScript Interview Questions: Arrays &#124; Kevin Chisholm Blog</dc:creator>
		<pubDate>Wed, 21 Mar 2012 05:45:39 +0000</pubDate>
		<guid isPermaLink="false">http://nfriedly.com/techblog/?p=106#comment-5705</guid>
		<description>[...] Hint: JavaScript arrays are Objects [...]</description>
		<content:encoded><![CDATA[<p>[...] Hint: JavaScript arrays are Objects [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: shawn</title>
		<link>http://nfriedly.com/techblog/2009/06/advanced-javascript-objects-arrays-and-array-like-objects/comment-page-1/#comment-5482</link>
		<dc:creator>shawn</dc:creator>
		<pubDate>Tue, 07 Feb 2012 17:27:33 +0000</pubDate>
		<guid isPermaLink="false">http://nfriedly.com/techblog/?p=106#comment-5482</guid>
		<description>@Frank,

There is a &#039;quick&#039; way to code it if you are on a modern (ECMASCript 5) environment:

var filtered = detailsArray.filter( function(value) {
            return value.moduleKey === &#039;attendanceindex&#039;;
        });</description>
		<content:encoded><![CDATA[<p>@Frank,</p>
<p>There is a &#8216;quick&#8217; way to code it if you are on a modern (ECMASCript 5) environment:</p>
<p>var filtered = detailsArray.filter( function(value) {<br />
            return value.moduleKey === &#8216;attendanceindex&#8217;;<br />
        });</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: JavaScript Interview Questions: Arrays &#124; JavaScript Mountain</title>
		<link>http://nfriedly.com/techblog/2009/06/advanced-javascript-objects-arrays-and-array-like-objects/comment-page-1/#comment-5472</link>
		<dc:creator>JavaScript Interview Questions: Arrays &#124; JavaScript Mountain</dc:creator>
		<pubDate>Wed, 01 Feb 2012 06:26:19 +0000</pubDate>
		<guid isPermaLink="false">http://nfriedly.com/techblog/?p=106#comment-5472</guid>
		<description>[...] Hint: JavaScript arrays are Objects [...]</description>
		<content:encoded><![CDATA[<p>[...] Hint: JavaScript arrays are Objects [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Quora</title>
		<link>http://nfriedly.com/techblog/2009/06/advanced-javascript-objects-arrays-and-array-like-objects/comment-page-1/#comment-5470</link>
		<dc:creator>Quora</dc:creator>
		<pubDate>Mon, 30 Jan 2012 13:26:52 +0000</pubDate>
		<guid isPermaLink="false">http://nfriedly.com/techblog/?p=106#comment-5470</guid>
		<description>&lt;strong&gt;Why do arrays work as objects in JavaScript?...&lt;/strong&gt;

go to this link:-http://nfriedly.com/techblog/2009/06/advanced-javascript-objects-arrays-and-array-like-objects/...</description>
		<content:encoded><![CDATA[<p><strong>Why do arrays work as objects in JavaScript?&#8230;</strong></p>
<p>go to this link:-http://nfriedly.com/techblog/2009/06/advanced-javascript-objects-arrays-and-array-like-objects/&#8230;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: nFriedly</title>
		<link>http://nfriedly.com/techblog/2009/06/advanced-javascript-objects-arrays-and-array-like-objects/comment-page-1/#comment-5467</link>
		<dc:creator>nFriedly</dc:creator>
		<pubDate>Tue, 24 Jan 2012 08:41:28 +0000</pubDate>
		<guid isPermaLink="false">http://nfriedly.com/techblog/?p=106#comment-5467</guid>
		<description>Yep, that&#039;s another good way to do it :)</description>
		<content:encoded><![CDATA[<p>Yep, that&#8217;s another good way to do it <img src='http://nfriedly.com/techblog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Mark</title>
		<link>http://nfriedly.com/techblog/2009/06/advanced-javascript-objects-arrays-and-array-like-objects/comment-page-1/#comment-5465</link>
		<dc:creator>Mark</dc:creator>
		<pubDate>Mon, 23 Jan 2012 16:48:08 +0000</pubDate>
		<guid isPermaLink="false">http://nfriedly.com/techblog/?p=106#comment-5465</guid>
		<description>Frank,

I would take a look at your design and see if objectArray could instead be an Object, and not an Array.  If so, I&#039;d change it&#039;s name to objectLookup, and then finding a module with &quot;attendanceindex&quot; is O(1).

 [js]   var objectLookup = {
       attendanceindex : 
         {
	        moduleKey: &quot;attendancecalendar&quot;,
	        iframe: true,
	        innerWidth: 500,
	        innerHeight: 350,
	        opacity: 0.35,
	        scrolling: false,
	        identifierType: &quot;href&quot;
	 },
         // ...rest of contents of objectArray
    };

    //then later..
    var winner = objectLookup.attendanceindex;[/js]</description>
		<content:encoded><![CDATA[<p>Frank,</p>
<p>I would take a look at your design and see if objectArray could instead be an Object, and not an Array.  If so, I&#8217;d change it&#8217;s name to objectLookup, and then finding a module with &#8220;attendanceindex&#8221; is O(1).</p>
<pre class="brush: jscript; title: ; notranslate">   var objectLookup = {
       attendanceindex :
         {
	        moduleKey: &quot;attendancecalendar&quot;,
	        iframe: true,
	        innerWidth: 500,
	        innerHeight: 350,
	        opacity: 0.35,
	        scrolling: false,
	        identifierType: &quot;href&quot;
	 },
         // ...rest of contents of objectArray
    };

    //then later..
    var winner = objectLookup.attendanceindex;</pre>
]]></content:encoded>
	</item>
	<item>
		<title>By: nFriedly</title>
		<link>http://nfriedly.com/techblog/2009/06/advanced-javascript-objects-arrays-and-array-like-objects/comment-page-1/#comment-5140</link>
		<dc:creator>nFriedly</dc:creator>
		<pubDate>Wed, 18 Jan 2012 04:07:56 +0000</pubDate>
		<guid isPermaLink="false">http://nfriedly.com/techblog/?p=106#comment-5140</guid>
		<description>Hi Frank,

There&#039;s no &quot;quick&quot; way to do it, you&#039;d just need to loop through the entire list and check each one until you find it:

[js]
var winner;
for(var i=0; i&lt; detailsArray.length; i++) {
  if(detailsArray[i].moduleKey === &quot;attendanceindex&quot;) {
    winner == detailsArray[i];
    break;
  }
}[/js]

Note, I said &quot;quick&quot; in quotes because in reality even with 1000 items in the array it took 0.005 seconds on my laptop (I tested it).</description>
		<content:encoded><![CDATA[<p>Hi Frank,</p>
<p>There&#8217;s no &#8220;quick&#8221; way to do it, you&#8217;d just need to loop through the entire list and check each one until you find it:</p>
<pre class="brush: jscript; title: ; notranslate">
var winner;
for(var i=0; i&lt; detailsArray.length; i++) {
  if(detailsArray[i].moduleKey === &quot;attendanceindex&quot;) {
    winner == detailsArray[i];
    break;
  }
}</pre>
<p>Note, I said &#8220;quick&#8221; in quotes because in reality even with 1000 items in the array it took 0.005 seconds on my laptop (I tested it).</p>
]]></content:encoded>
	</item>
</channel>
</rss>

