Is HTML Collection not an array but an object? When I log into console typeof(lis) it shows object not array.
Is HTML Collection not an array but an object? When I log into console typeof(lis) it shows object not array. Also I can not use forEach() on it, however for in loop works perfectly fine. If that is the case why can I use for loop to iterate over lis as well?
Steven Parker195,561 Points
HTMLCollection is what is known as an "array-like object", which is iterable and offers a few methods and properties for selecting items within it.
Another interesting aspect is that it is "live", meaning that it is updated whenever changes are made to the DOM.
For more details, see the MDN page on HTMLCollection.
Thank you Steven Parker. You are always there with answers. You are my hero!