`for ... of ...` vs `.forEach`
Opened this issue · 1 comments
ccouzens commented
Do we have a preference for if we use:
const array = [1, 2, 3, 4];
for (const item of array) {
console.log(item);
}
// or
array.forEach((item) => {
console.log(item);
});
There is an eslint plugin that enforces a style. The arguments are quite one-sided, but I agree with it.
I was inspired to ask by this bit of code
https://github.com/loveholidays/aurora/blob/3a5223d3680c35c5a494f3526e14f728a018d416/src/apis/content-repository/ContentRepositoryApi.ts#L155
dios-david commented
Personally I don't see an issue with having both, but if I had to pick only one then I would keep .forEach
I think this is more like an imperative vs declarative argument, I vote for declarative