Let's say I have an HTMLCollection:
const appElem = document.querySelector("#app");
const appChildren = appElem?.children; // HTML collection
now if I convert this collection to an array it will be Element[]
:
const appChildrenArr = appChildren && Array.from(appChildren); // Element[]
But why appChildrenArr
has Element[]
type, not HTMLElement[]
type?
CodePudding user response:
Because they don't have to be HTMLElements. You could have an SVGElement there, as well, for example.