About "for...of": I find myself using it often with async/await. Foreach() does not work well with asynchronous code. I think this was the author's point.
For more background see this: stackoverflow.com/questions/375766...
It depends. If you want to wait on a list of promises returned by an array of functions, better use await Promise.all(fns.map(fn => fn()), as it will allow you to run them parallel.
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
#4: you may want to consider using the nullish coalescing operator
??(use||consciously if you want to catch all falsy types).#6:
for...ofis not neccessarily more readable thanforEach, especially if you use arrow functions.#7: you can use
Object.assignon DOM elements, e.g.About "for...of": I find myself using it often with async/await. Foreach() does not work well with asynchronous code. I think this was the author's point.
For more background see this: stackoverflow.com/questions/375766...
It depends. If you want to wait on a list of promises returned by an array of functions, better use
await Promise.all(fns.map(fn => fn()), as it will allow you to run them parallel.