To define the number of nodes in a node list, use the length property.
Example
You can try to run the following code to learn how to implement length property in JavaScript −
<!DOCTYPE html>
<html>
<body>
<p>Demo Text1</p>
<p id = "pid"></p>
<script>
var myLen = document.querySelectorAll("p");
document.getElementById("pid").innerHTML = "This document has " + myLen.length + " paragraph tags.";
</script>
</body>
</html>