I know how to use forEach
in general but today I hit a spot that puzzled me. I've googled it but didn't get anything that I didn't already know.
I'm starting with TypeScript because of Angular and I've accessed a set of controls from the DOM. Then, I pick one of them and get to its children.
@ViewChildren("marker") markers: QueryList<ElementRef>;
this.markers.forEach(item => {
let element = item.nativeElement;
//item.children.forEach(child => {child.classList.add("poof"); });
for (let child of element.children)
child.classList.add("poof");
});
According to the console, it looks like an array, as it's a list with brackets (although typeof
tells me it's an object).
I'm confused about this and curious about why the commented out code doesn't work. Not sure what to google for, neither.