scripts.contact wrote:
On Mar 29, 9:46 am, Noah Sussman wrote:
>>'document.getElementByTagName('p')[0]'.
What is happening here is that you are creating an
array, and dereferencing the array, both on the same
line. document.getElementsByTagName('p') gets an array
It's not array, it's a collection.
The object returned from - getelementsByTagName - is a - NodeList
- not a collection. In a class-less language like ECMAScript being
a - NodeList - is just a matter of having the specified properties,
methods and characteristics of a - NodeList -, and as a result all
objects implementing the - HTMLCollection - interface are also
implementing the - NodeList - interface (so are NodeLists). But
NodeLists are not necessarily also HTMLCollections, and it would
be dangerous to assume that the objects returend from calls to
- getElementsById - have properties beyond those specified.
In class-based terminology it may be said that - HTMLCollection
- extends - NodeList, and actual examples may be implemented in
that way. In such a context it would be possible to case an -
HTMLCollection - into a - NodeList -, but not the other way around.
Richard.