Array part 3

Accessing an Array



Attempting to access an index outside of the array, returns the value undefined.
var courses = new Array("HTML", "CSS", "JS");
document.write(courses[10]);
//Outputs "undefined"
Try It Yourself

Our courses array has just 3 elements, so the 10th index, which is the 11th element, does not exist (is undefined).

Comments

Popular posts from this blog

String Operators

Introducing object part 3

Associative Arrays part 2