[url=http://andrewdupont.net/2006/05/18/javascript-associative-arrays-considered-harmful/]《JavaScript “Associative Arrays” Considered Harmful》[/url]):
[quote]
JavaScript arrays (which are meant to be numeric) are often used to hold key/value pairs. This is bad practice. Object should be used instead.
//大意:[b]数组只支持数字的,键值对应使用于对象上。[/b]
[/quote]There is no way to specify string keys in an array constructor. //在数组构造函数中无法定义字符串键值
There is no way to specify string keys in an array literal. //在数组字面量中无法定义字符串键值
Array.length does not count them as items. // Array.length 不会计算字符串键值
进一步窥探数组:
1、数组可以根据所赋的值自动调整大小
[url=http://west-wind.com/Weblog/posts/608772.aspx]《Javascript Array Fun》[/url] [/list]
2、可使用[b]“The Miller Device”[/b] 方法来判断是否是数组
[url=http://blog.360.yahoo.com/blog-TBPekxc1dLNy5DOloPfzVvFIVOWMB0li?p=916]《The Miller Device》[/url]
[*][url=http://ajaxian.com/archives/isarray-why-is-it-so-bloody-hard-to-get-right]《isArray: Why is it so bloody hard to get right?》[/url] [/*][/list]