<?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>评论：有趣而诡异的数组</title>
	<atom:link href="http://www.planabc.net/2009/02/02/javascript_array_fun/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.planabc.net/2009/02/02/javascript_array_fun/</link>
	<description>落草为根—专注前端技术&#38;&#38;关注用户体验</description>
	<lastBuildDate>Mon, 15 Mar 2010 14:10:42 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>来自：jianxianxia</title>
		<link>http://www.planabc.net/2009/02/02/javascript_array_fun/comment-page-1/#comment-5479</link>
		<dc:creator>jianxianxia</dc:creator>
		<pubDate>Mon, 07 Dec 2009 01:19:13 +0000</pubDate>
		<guid isPermaLink="false">http://www.planabc.net/?p=185#comment-5479</guid>
		<description>如果是associative_array[&#039;0&#039;] = &#039;0&#039;;
associative_array[&#039;1&#039;] = &#039;1&#039;;
associative_array[&#039;2&#039;] = &#039;2&#039;;
alert(associative_array.length);弹出数组长度为3，这个又怎么解释呢，同样数组的下标为字符型</description>
		<content:encoded><![CDATA[<p>如果是associative_array['0'] = &#8216;0&#8242;;<br />
associative_array['1'] = &#8216;1&#8242;;<br />
associative_array['2'] = &#8216;2&#8242;;<br />
alert(associative_array.length);弹出数组长度为3，这个又怎么解释呢，同样数组的下标为字符型</p>
]]></content:encoded>
	</item>
	<item>
		<title>来自：dongyuwei</title>
		<link>http://www.planabc.net/2009/02/02/javascript_array_fun/comment-page-1/#comment-3367</link>
		<dc:creator>dongyuwei</dc:creator>
		<pubDate>Sat, 09 May 2009 14:41:08 +0000</pubDate>
		<guid isPermaLink="false">http://www.planabc.net/?p=185#comment-3367</guid>
		<description>The Miller Device方法判断是否是数组，个人感觉没有以duck type的方式好。</description>
		<content:encoded><![CDATA[<p>The Miller Device方法判断是否是数组，个人感觉没有以duck type的方式好。</p>
]]></content:encoded>
	</item>
	<item>
		<title>来自：KingFo</title>
		<link>http://www.planabc.net/2009/02/02/javascript_array_fun/comment-page-1/#comment-3087</link>
		<dc:creator>KingFo</dc:creator>
		<pubDate>Tue, 24 Mar 2009 16:17:25 +0000</pubDate>
		<guid isPermaLink="false">http://www.planabc.net/?p=185#comment-3087</guid>
		<description>厄 竟然重复了一条。。。  BZ帮忙删一个吧。。。。</description>
		<content:encoded><![CDATA[<p>厄 竟然重复了一条。。。  BZ帮忙删一个吧。。。。</p>
]]></content:encoded>
	</item>
	<item>
		<title>来自：KingFo</title>
		<link>http://www.planabc.net/2009/02/02/javascript_array_fun/comment-page-1/#comment-3085</link>
		<dc:creator>KingFo</dc:creator>
		<pubDate>Tue, 24 Mar 2009 16:16:35 +0000</pubDate>
		<guid isPermaLink="false">http://www.planabc.net/?p=185#comment-3085</guid>
		<description>恩 如果在AS中 Array 可以当作字典或者Map用
如第一部分形式类似
于是 在AS中比较猥琐的方法就是借用负数快速倒序排列
如a[-1]
当然 length==0

嘿嘿  我又来八AS了</description>
		<content:encoded><![CDATA[<p>恩 如果在AS中 Array 可以当作字典或者Map用<br />
如第一部分形式类似<br />
于是 在AS中比较猥琐的方法就是借用负数快速倒序排列<br />
如a[-1]<br />
当然 length==0</p>
<p>嘿嘿  我又来八AS了</p>
]]></content:encoded>
	</item>
	<item>
		<title>来自：虫虫舞</title>
		<link>http://www.planabc.net/2009/02/02/javascript_array_fun/comment-page-1/#comment-3057</link>
		<dc:creator>虫虫舞</dc:creator>
		<pubDate>Thu, 19 Mar 2009 07:45:08 +0000</pubDate>
		<guid isPermaLink="false">http://www.planabc.net/?p=185#comment-3057</guid>
		<description>可以向您请教一下，您在文章里面的代码部分写在方框里的效果是怎样实现的吗？</description>
		<content:encoded><![CDATA[<p>可以向您请教一下，您在文章里面的代码部分写在方框里的效果是怎样实现的吗？</p>
]]></content:encoded>
	</item>
	<item>
		<title>来自：diyism</title>
		<link>http://www.planabc.net/2009/02/02/javascript_array_fun/comment-page-1/#comment-3043</link>
		<dc:creator>diyism</dc:creator>
		<pubDate>Mon, 16 Mar 2009 10:29:18 +0000</pubDate>
		<guid isPermaLink="false">http://www.planabc.net/?p=185#comment-3043</guid>
		<description>javascript要是像php数组那样多好, 支持number索引, 也支持character索引, 免得总是用object来模仿数组了, 我觉得描述这个世界最方便的是treemap, 而不是object,
treemap类型:
python里是dictionary,
java中是treemap/hashmap用起来很不方便(很多put),
ruby中是hash(键可以是数字,字串或其它),
php中是array,
js里是object(用方括号当数组).</description>
		<content:encoded><![CDATA[<p>javascript要是像php数组那样多好, 支持number索引, 也支持character索引, 免得总是用object来模仿数组了, 我觉得描述这个世界最方便的是treemap, 而不是object,<br />
treemap类型:<br />
python里是dictionary,<br />
java中是treemap/hashmap用起来很不方便(很多put),<br />
ruby中是hash(键可以是数字,字串或其它),<br />
php中是array,<br />
js里是object(用方括号当数组).</p>
]]></content:encoded>
	</item>
	<item>
		<title>来自：mAmimoluo</title>
		<link>http://www.planabc.net/2009/02/02/javascript_array_fun/comment-page-1/#comment-3000</link>
		<dc:creator>mAmimoluo</dc:creator>
		<pubDate>Thu, 12 Mar 2009 00:51:09 +0000</pubDate>
		<guid isPermaLink="false">http://www.planabc.net/?p=185#comment-3000</guid>
		<description>关于正确判断数组的方法的首创者是prototype.js的维护着kangax提出的。
下面给出一种通用判断对象类型的方法：
var is =
{
   types : [&quot;Array&quot;, &quot;Boolean&quot;, &quot;Date&quot;, &quot;Number&quot;, &quot;Object&quot;, &quot;RegExp&quot;, &quot;String&quot;, &quot;Window&quot;, &quot;HTMLDocument&quot;]
}
;
for(var i = 0, c; c = is.types[i ++ ]; )
{
   is[c] = (function(type)
   {
      return function(obj)
      {
         return Object.prototype.toString.call(obj) == &quot;[object &quot; + type + &quot;]&quot;;
      }
   }
   )(c);
}
alert(is.Array([])); // true
alert(is.Date(new Date)); // true
alert(is.RegExp(/reg/ig)); // true

关于具体的探讨请参考我的博客：http://hi.baidu.com/mimimo/blog/item/2240974580104b3887947387.html</description>
		<content:encoded><![CDATA[<p>关于正确判断数组的方法的首创者是prototype.js的维护着kangax提出的。<br />
下面给出一种通用判断对象类型的方法：<br />
var is =<br />
{<br />
   types : ["Array", "Boolean", "Date", "Number", "Object", "RegExp", "String", "Window", "HTMLDocument"]<br />
}<br />
;<br />
for(var i = 0, c; c = is.types[i ++ ]; )<br />
{<br />
   is[c] = (function(type)<br />
   {<br />
      return function(obj)<br />
      {<br />
         return Object.prototype.toString.call(obj) == &#8220;[object " + type + "]&#8220;;<br />
      }<br />
   }<br />
   )(c);<br />
}<br />
alert(is.Array([])); // true<br />
alert(is.Date(new Date)); // true<br />
alert(is.RegExp(/reg/ig)); // true</p>
<p>关于具体的探讨请参考我的博客：http://hi.baidu.com/mimimo/blog/item/2240974580104b3887947387.html</p>
]]></content:encoded>
	</item>
	<item>
		<title>来自：lonqi</title>
		<link>http://www.planabc.net/2009/02/02/javascript_array_fun/comment-page-1/#comment-2798</link>
		<dc:creator>lonqi</dc:creator>
		<pubDate>Mon, 16 Feb 2009 06:11:32 +0000</pubDate>
		<guid isPermaLink="false">http://www.planabc.net/?p=185#comment-2798</guid>
		<description>学习了，刚开始的时候倒是没有发现问题所在，仔细一看原来是键值为非数值字符了。。</description>
		<content:encoded><![CDATA[<p>学习了，刚开始的时候倒是没有发现问题所在，仔细一看原来是键值为非数值字符了。。</p>
]]></content:encoded>
	</item>
	<item>
		<title>来自：琳琳的小狗</title>
		<link>http://www.planabc.net/2009/02/02/javascript_array_fun/comment-page-1/#comment-2791</link>
		<dc:creator>琳琳的小狗</dc:creator>
		<pubDate>Sun, 15 Feb 2009 12:03:53 +0000</pubDate>
		<guid isPermaLink="false">http://www.planabc.net/?p=185#comment-2791</guid>
		<description>顺便，to digibread：
你看到的这个东西，叫做“自执行函数”，属于js中比较常见的模式之一，可以用来划分命名空间等等，在这里的用途，主要是因为需要修正闭包共享变量的问题，要是不这么写，你会发现六个type最终都会变成“Object”：）</description>
		<content:encoded><![CDATA[<p>顺便，to digibread：<br />
你看到的这个东西，叫做“自执行函数”，属于js中比较常见的模式之一，可以用来划分命名空间等等，在这里的用途，主要是因为需要修正闭包共享变量的问题，要是不这么写，你会发现六个type最终都会变成“Object”：）</p>
]]></content:encoded>
	</item>
	<item>
		<title>来自：琳琳的小狗</title>
		<link>http://www.planabc.net/2009/02/02/javascript_array_fun/comment-page-1/#comment-2790</link>
		<dc:creator>琳琳的小狗</dc:creator>
		<pubDate>Sun, 15 Feb 2009 11:57:52 +0000</pubDate>
		<guid isPermaLink="false">http://www.planabc.net/?p=185#comment-2790</guid>
		<description>啊哈，又一次看到“数组检测”。前一阵儿刚俺也发了篇文章介绍这个方法，不同的是，也把原理翻译过来了，详情可以参考：
《Javascript数组类型检测：编写更强壮的isArray函数》
http://scriptfans.javaeye.com/blog/318821</description>
		<content:encoded><![CDATA[<p>啊哈，又一次看到“数组检测”。前一阵儿刚俺也发了篇文章介绍这个方法，不同的是，也把原理翻译过来了，详情可以参考：<br />
《Javascript数组类型检测：编写更强壮的isArray函数》<br />
<a href="http://scriptfans.javaeye.com/blog/318821" rel="nofollow">http://scriptfans.javaeye.com/blog/318821</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>来自：亚洲色图</title>
		<link>http://www.planabc.net/2009/02/02/javascript_array_fun/comment-page-1/#comment-2742</link>
		<dc:creator>亚洲色图</dc:creator>
		<pubDate>Tue, 10 Feb 2009 03:04:05 +0000</pubDate>
		<guid isPermaLink="false">http://www.planabc.net/?p=185#comment-2742</guid>
		<description>学习  技术不懂 呵呵·</description>
		<content:encoded><![CDATA[<p>学习  技术不懂 呵呵·</p>
]]></content:encoded>
	</item>
	<item>
		<title>来自：擎天</title>
		<link>http://www.planabc.net/2009/02/02/javascript_array_fun/comment-page-1/#comment-2734</link>
		<dc:creator>擎天</dc:creator>
		<pubDate>Mon, 09 Feb 2009 02:53:36 +0000</pubDate>
		<guid isPermaLink="false">http://www.planabc.net/?p=185#comment-2734</guid>
		<description>alert(associative_array.constructor == Array);</description>
		<content:encoded><![CDATA[<p>alert(associative_array.constructor == Array);</p>
]]></content:encoded>
	</item>
	<item>
		<title>来自：脚本爱好者</title>
		<link>http://www.planabc.net/2009/02/02/javascript_array_fun/comment-page-1/#comment-2699</link>
		<dc:creator>脚本爱好者</dc:creator>
		<pubDate>Thu, 05 Feb 2009 05:23:26 +0000</pubDate>
		<guid isPermaLink="false">http://www.planabc.net/?p=185#comment-2699</guid>
		<description>其实开始声明为什么类型不重要 ，关键是当什么类型去使用。

同样， 你要是将数组赋值为一个字符串，那么他就是一个字符串。
比如:
	var arr = [];
	arr = &quot;asdasd&quot;;
	alert(arr.length)
弹出结果为6</description>
		<content:encoded><![CDATA[<p>其实开始声明为什么类型不重要 ，关键是当什么类型去使用。</p>
<p>同样， 你要是将数组赋值为一个字符串，那么他就是一个字符串。<br />
比如:<br />
	var arr = [];<br />
	arr = &#8220;asdasd&#8221;;<br />
	alert(arr.length)<br />
弹出结果为6</p>
]]></content:encoded>
	</item>
	<item>
		<title>来自：kyan</title>
		<link>http://www.planabc.net/2009/02/02/javascript_array_fun/comment-page-1/#comment-2697</link>
		<dc:creator>kyan</dc:creator>
		<pubDate>Thu, 05 Feb 2009 01:39:04 +0000</pubDate>
		<guid isPermaLink="false">http://www.planabc.net/?p=185#comment-2697</guid>
		<description>associative_array[&quot;one&quot;] = &quot;1″;
associative_array[&quot;two&quot;] = &quot;2″;
associative_array[&quot;three&quot;] = &quot;3″;

这样的写法是为数组associative_array增加来三个属性而已，和长度无关。等同写法：associative_array.one= &quot;1&quot;;
associative_array.two= &quot;2&quot;;
associative_array.three= &quot;3&quot;;</description>
		<content:encoded><![CDATA[<p>associative_array["one"] = &#8220;1″;<br />
associative_array["two"] = &#8220;2″;<br />
associative_array["three"] = &#8220;3″;</p>
<p>这样的写法是为数组associative_array增加来三个属性而已，和长度无关。等同写法：associative_array.one= &#8220;1&#8243;;<br />
associative_array.two= &#8220;2&#8243;;<br />
associative_array.three= &#8220;3&#8243;;</p>
]]></content:encoded>
	</item>
	<item>
		<title>来自：kyan</title>
		<link>http://www.planabc.net/2009/02/02/javascript_array_fun/comment-page-1/#comment-2696</link>
		<dc:creator>kyan</dc:creator>
		<pubDate>Thu, 05 Feb 2009 01:33:16 +0000</pubDate>
		<guid isPermaLink="false">http://www.planabc.net/?p=185#comment-2696</guid>
		<description>associative_array[&quot;one&quot;] = &quot;1&quot;;
associative_array[&quot;two&quot;] = &quot;2&quot;;associative_array[&quot;three&quot;] = &quot;3&quot;;</description>
		<content:encoded><![CDATA[<p>associative_array["one"] = &#8220;1&#8243;;<br />
associative_array["two"] = &#8220;2&#8243;;associative_array["three"] = &#8220;3&#8243;;</p>
]]></content:encoded>
	</item>
	<item>
		<title>来自：vampire</title>
		<link>http://www.planabc.net/2009/02/02/javascript_array_fun/comment-page-1/#comment-2693</link>
		<dc:creator>vampire</dc:creator>
		<pubDate>Wed, 04 Feb 2009 16:39:34 +0000</pubDate>
		<guid isPermaLink="false">http://www.planabc.net/?p=185#comment-2693</guid>
		<description>前面的框都见过 最后那个框确实很有想法 你很有才
那个for循环的用法很有意思 就是可读性差了点 呵呵

刚刚留言的时候你博客突然变得很慢 然后就乱码了。。。</description>
		<content:encoded><![CDATA[<p>前面的框都见过 最后那个框确实很有想法 你很有才<br />
那个for循环的用法很有意思 就是可读性差了点 呵呵</p>
<p>刚刚留言的时候你博客突然变得很慢 然后就乱码了。。。</p>
]]></content:encoded>
	</item>
	<item>
		<title>来自：怿飞</title>
		<link>http://www.planabc.net/2009/02/02/javascript_array_fun/comment-page-1/#comment-2684</link>
		<dc:creator>怿飞</dc:creator>
		<pubDate>Tue, 03 Feb 2009 03:53:23 +0000</pubDate>
		<guid isPermaLink="false">http://www.planabc.net/?p=185#comment-2684</guid>
		<description>@igibread 可以简化成：
var a =function(type){
……
};
is[c] = a(c);</description>
		<content:encoded><![CDATA[<p>@igibread 可以简化成：<br />
var a =function(type){<br />
……<br />
};<br />
is[c] = a(c);</p>
]]></content:encoded>
	</item>
	<item>
		<title>来自：rainoxu</title>
		<link>http://www.planabc.net/2009/02/02/javascript_array_fun/comment-page-1/#comment-2683</link>
		<dc:creator>rainoxu</dc:creator>
		<pubDate>Tue, 03 Feb 2009 03:52:01 +0000</pubDate>
		<guid isPermaLink="false">http://www.planabc.net/?p=185#comment-2683</guid>
		<description>var associative_array = [];
associative_array[&quot;raino&quot;]=&quot;rainoxu&quot;;
alert(associative_array [&quot;raino&quot;]==&quot;rainoxu&quot;)
alert(associative_array.length)

使用是可以的,但是长度为0,好像在某本书上看到过这个例子,虽然有点不同,可惜那本书上没有解释,但是如果碰到这种情况,为了避免误会的话,还是用对象更安全,至少不会出错了~~</description>
		<content:encoded><![CDATA[<p>var associative_array = [];<br />
associative_array["raino"]=&#8221;rainoxu&#8221;;<br />
alert(associative_array ["raino"]==&#8221;rainoxu&#8221;)<br />
alert(associative_array.length)</p>
<p>使用是可以的,但是长度为0,好像在某本书上看到过这个例子,虽然有点不同,可惜那本书上没有解释,但是如果碰到这种情况,为了避免误会的话,还是用对象更安全,至少不会出错了~~</p>
]]></content:encoded>
	</item>
	<item>
		<title>来自：digibread</title>
		<link>http://www.planabc.net/2009/02/02/javascript_array_fun/comment-page-1/#comment-2682</link>
		<dc:creator>digibread</dc:creator>
		<pubDate>Tue, 03 Feb 2009 03:49:09 +0000</pubDate>
		<guid isPermaLink="false">http://www.planabc.net/?p=185#comment-2682</guid>
		<description>非常实用，有个问题请教：
is[c] = (function(type){
        ……        }
    })(c);
有时会看到这样的结构，请问这是什么语法结构？我手头上的参考书没有这方面的介绍，所以这部分的代码读不懂。能否给个这方面的参考连接？谢谢</description>
		<content:encoded><![CDATA[<p>非常实用，有个问题请教：<br />
is[c] = (function(type){<br />
        ……        }<br />
    })(c);<br />
有时会看到这样的结构，请问这是什么语法结构？我手头上的参考书没有这方面的介绍，所以这部分的代码读不懂。能否给个这方面的参考连接？谢谢</p>
]]></content:encoded>
	</item>
	<item>
		<title>来自：kingmax</title>
		<link>http://www.planabc.net/2009/02/02/javascript_array_fun/comment-page-1/#comment-2681</link>
		<dc:creator>kingmax</dc:creator>
		<pubDate>Tue, 03 Feb 2009 03:14:37 +0000</pubDate>
		<guid isPermaLink="false">http://www.planabc.net/?p=185#comment-2681</guid>
		<description>看来博主的javascript基本功还不行。。。</description>
		<content:encoded><![CDATA[<p>看来博主的javascript基本功还不行。。。</p>
]]></content:encoded>
	</item>
</channel>
</rss>
