TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Understanding JavaScript Arrays

34 pointsby heseltinealmost 15 years ago

4 comments

svnvalmost 15 years ago
Isn't this faster for iterating over the elements:<p><pre><code> var a = ["banana", Math.min, 4, "apple"]; for (var i=a.length; i; i--) { console.log(a[i]); }</code></pre>
评论 #1554220 未加载
评论 #1544739 未加载
评论 #1544736 未加载
评论 #1545080 未加载
ccollinsalmost 15 years ago
I want to stress that the following will work, but get you in trouble. Javascript does not support associative arrays.<p><pre><code> var myData = new Array; myData['key1'] = 'value1'; myData['key2'] = 'value2'; myData['key3'] = 'value3'; myData.length; //0</code></pre>
评论 #1544108 未加载
messelalmost 15 years ago
forEach,map, and several other ECMA5 methods look like a joy to use
msiealmost 15 years ago
This isn't your father's Array. Sigh.