Closed willeastcott closed 1 year ago
Why prefer for of to forEach?
@slimbuck I'll admit this is a personal preference when I am stepping through a loop. With forEach, you have to set a breakpoint in the function, but with for...of, you can just single step through loop iterations. So yeah, I just generally prefer to use for...of
where it can be.
And also worth mentioning that forEach
is worse for performance than for...of
. See:
https://leanylabs.com/blog/js-forEach-map-reduce-vs-for-for_of/
This PR:
for...of
loops to iterate thechildNodes
array where possible (easier to step thanforEach
and terser than afor
loop).any
types fromTreeView.ts
.tsconfig.json
files to allowdom.iterable
related code (which permits use offor...of
for iteratingchildNodes
. See this for more info ondom.iterable
.