Back to Content

NamedNodeMap: length property

files/en-us/web/api/namednodemap/length/index.md

latest571 B
Original Source

{{APIRef("DOM")}}

The read-only length property of the {{domxref("NamedNodeMap")}} interface is the number of objects stored in the map.

Value

A number containing the number of objects in the map

Example

html
<pre class="foo" id="bar" contenteditable></pre>
js
const pre = document.querySelector("pre");
const attrMap = pre.attributes;
pre.textContent = `The 'test' attribute contains ${attrMap.length} attributes.\n`;

{{EmbedLiveSample("Example", "100%", 20)}}

Specifications

{{Specifications}}

Browser compatibility

{{Compat}}