Array part 2

Accessing an Array



You refer to an array element by referring to the index number written in square brackets.
This statement accesses the value of the first element in courses and changes the value of the second element.var courses = new Array("HTML", "CSS", "JS");
var course = courses[0]; // HTML
courses[1] = "C++"; //Changes the second element

[0] is the first element in an array. [1] is the second. Array indexes start with 0.

Comments

Popular posts from this blog

String Operators

Introducing object part 3

The math object part 2