I come from python background so spare me the criticism if this sounds silly. But I have three elements from the dom that I have stored in their separate variable and then made an array out of those variables.
var item = document.getElementById("s-tools");
var item2 = document.getElementById("s-tools2");
var item3 = document.getElementById("s-tools3");
var arr = [item, item2, item3]
Now I am trying to iterate over this array of dom objects in my for loop and remove child elements from these items.
for (var item in arr) {
while (item.hasChildNodes()) {
item.removeChild(item.lastChild);
}
}
then it is throwing the following error and value in item is 0
Uncaught TypeError: item.hasChildNodes is not a function