O'Reilly logo
  • Ahmed Elgendy thinks this is interesting:

You said getElementsByTagName returns a list. Do you mean an array?


A: It returns an object that you can treat like an array, but it’s actually an object called a NodeList. A NodeList is a collection of Nodes, which is just a technical name for the element objects that you see in the DOM tree. You can iterate over this collection by getting its length using the length property, and then access each item in the NodeList using an index with the b...


Cover of Head First JavaScript Programming


What does getElementsByTagName return and how is it different from what getElementsById's returns? A tip: The first returns anything from zero tag to a finite number of tags but the second returns one id because when you assign ids to tags, each tag gets its own unique id.