www.wd4e.com

Arrays

Finally!! Now is when I start to explain some of the concepts I said you had to wait for. Hopefully by now you are comfortable with the code


document.getElementById('idName');

This code will cause the API to search the DOM until it finds a node with the id of 'idName'). The key is that it is returning a single Node. But what about these other functions?


document.getElementsByTagName('p');
document.getElementsByClassName('thumbnail');

These commands may return zero, one or more Nodes. So now we need to find a way to handle dealing with collections of data, rather than just one thing at a time. This is where Arrays come in. Let's get started.