JavaScript Array Basics

  You are currently not logged in. You can view the forums, but cannot post messages. Log In | Register

05-May-08 00:00
This is a forum topic for discussing the article "JavaScript Array Basics":

http://www.elated.com/articles/javascript-array-basics/

Learn how to use JavaScript arrays. In this tutorial you learn what a JavaScript array is, how to create an array, how to access an array's contents, how array lengths work, and how to loop through arrays.
07-Dec-10 03:20
This is an optimization of the loop:

for(var i=0, len=myArray.length; i < len; i++){}

as the length is "cached" and not recalculated every time.

If you want to know more details about this topic, read my post http://bit.ly/arrayjs
11-Feb-13 05:17
In the Array length section it states:

"myArray[99] = "anotherValue";

If you set an array to be a certain length, all values within the array that have not been explicitly defined have the value undefined. So in the above example, myArray[0] contains "myValue", and myArray[1] – myArray[99] all contain the value undefined."

Surely myArray[99] should be "anotherValue", not undefined, or am i mistaken?

Regards,
Clive

 
New posts
Old posts

Follow Elated