NamedNodeMap(W3C DOM Core object)

Example

var collection = node.attributes;

The example above creates a reference to the attributes collection of a Node. If
there were an attribute in that collection called
darth, it could be accessed as
collection['darth'] or
collection.getNamedItem('darth').

If we knew it
was, say, the first item in the collection, it could also be accessed as
collection[0]; but since a
NamedNodeMap is not in any particular order, we
generally won't know our item's index. The ability to access the members
by index is designed to make it easy to iterate through a collection:

Description

The
NamedNodeMap interface represents an
unordered collection of items (such as nodes, or string values),
indexed by name.

It's also possible to access the items in a
NamedNodeMap by number (starting from zero), however
the DOM does not specify their order.

A named node map is a
live collection, which means that changes to the
collection it represents are immediately reflected in the node map (as
opposed to it being a static snapshot).

The nodeName is used as the name under which a node is
stored in a node map, which implies that for certain kinds of node — where
all instances have the same name (such as #text or
#comment) — it's not possible to store more than one
instance of such a node within a single node map, because the names would
clash. The DOM specification considers this preferable to implementing
aliases.

CAUTION: A node map is not an array

Even though a node map looks like an array, it isn't an array —
although you can iterate through it and refer to its members like an
array, you can't use Array methods like
push or pop on it.