--- source: crates/biome_js_analyze/tests/spec_tests.rs expression: invalid.js --- # Input ```jsx els.forEach((el) => {}); els.forEach(el => {}); els.forEach(() => {}); (els.forEach)((el) => {}); els['forEach']((el) => {}); (els['forEach'])((el) => {}); els.forEach(function(el) {}, thisArg); ``` # Diagnostics ``` invalid.js:1:1 lint/complexity/noForEach ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ! Prefer for...of instead of forEach. > 1 │ els.forEach((el) => {}); │ ^^^^^^^^^^^^^^^^^^^^^^^ 2 │ 3 │ els.forEach(el => {}); i forEach may lead to performance issues when working with large arrays. When combined with functions like filter or map, this causes multiple iterations over the same type. ``` ``` invalid.js:3:1 lint/complexity/noForEach ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ! Prefer for...of instead of forEach. 1 │ els.forEach((el) => {}); 2 │ > 3 │ els.forEach(el => {}); │ ^^^^^^^^^^^^^^^^^^^^^ 4 │ 5 │ els.forEach(() => {}); i forEach may lead to performance issues when working with large arrays. When combined with functions like filter or map, this causes multiple iterations over the same type. ``` ``` invalid.js:5:1 lint/complexity/noForEach ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ! Prefer for...of instead of forEach. 3 │ els.forEach(el => {}); 4 │ > 5 │ els.forEach(() => {}); │ ^^^^^^^^^^^^^^^^^^^^^ 6 │ 7 │ (els.forEach)((el) => {}); i forEach may lead to performance issues when working with large arrays. When combined with functions like filter or map, this causes multiple iterations over the same type. ``` ``` invalid.js:7:1 lint/complexity/noForEach ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ! Prefer for...of instead of forEach. 5 │ els.forEach(() => {}); 6 │ > 7 │ (els.forEach)((el) => {}); │ ^^^^^^^^^^^^^^^^^^^^^^^^^ 8 │ 9 │ els['forEach']((el) => {}); i forEach may lead to performance issues when working with large arrays. When combined with functions like filter or map, this causes multiple iterations over the same type. ``` ``` invalid.js:9:1 lint/complexity/noForEach ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ! Prefer for...of instead of forEach. 7 │ (els.forEach)((el) => {}); 8 │ > 9 │ els['forEach']((el) => {}); │ ^^^^^^^^^^^^^^^^^^^^^^^^^^ 10 │ 11 │ (els['forEach'])((el) => {}); i forEach may lead to performance issues when working with large arrays. When combined with functions like filter or map, this causes multiple iterations over the same type. ``` ``` invalid.js:11:1 lint/complexity/noForEach ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ! Prefer for...of instead of forEach. 9 │ els['forEach']((el) => {}); 10 │ > 11 │ (els['forEach'])((el) => {}); │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 12 │ 13 │ els.forEach(function(el) {}, thisArg); i forEach may lead to performance issues when working with large arrays. When combined with functions like filter or map, this causes multiple iterations over the same type. ``` ``` invalid.js:13:1 lint/complexity/noForEach ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ! Prefer for...of instead of forEach. 11 │ (els['forEach'])((el) => {}); 12 │ > 13 │ els.forEach(function(el) {}, thisArg); │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 14 │ i forEach may lead to performance issues when working with large arrays. When combined with functions like filter or map, this causes multiple iterations over the same type. ```