For instance we have one ul element with four li child element contained within!
then lets say the following code is executed int he console
var a = document.getElementsByTagName("ul");
a.childNodes.splice(1, 2, "abc", "cde");
TypeError: a.childNodes.splice is not a function
As MDN notes,
Why is NodeList not an Array?
NodeList are used very much like arrays and it's tempting to invoke Array.prototype methods on them, however NodeList objects don't have any of the familiar Array methods.
A work around will be to make it an array like this.
var nodesArray = .slice.call(a); //now call the splice method. nodesArray.childNodes.splice(1, 2, "abc", "cde");