Ranter
Join devRant
Do all the things like
++ or -- rants, post your own rants, comment on others' rants and build your customized dev avatar
Sign Up
Pipeless API
From the creators of devRant, Pipeless lets you power real-time personalized recommendations and activity feeds using a simple API
Learn More
Comments
-
If you want to process the array, just use map/filter, foreach is for using the items in a loop, it's not useless.
-
Foreach is the side effect in the function chain. It's not my preferred method, but it tracks.
-
C0D4681384yNow I'm more interested in a language that returns a value from said list that's called foreach() 🤨
It's really no different to expecting while(true) or for(i in 100000) to never return anything. -
irene33944y@theabbie @SortOfTested @C0D4 I get that it exists and that it works. I even use it. I just kind of hate it.
for(let x of foo) {
// 🖖
console.log(x);
}
const foo = foo.map((x)=> typeof x); // 🤟
foo.forEach((x)=> console.log(x)); // 🦶 -
irene33944y@SortOfTested Hah. I didn't think about that.
I guess the part that I hate most is when people have a giant functional chain then plop a forEach at the end. foo.filter(...).map(...).reduce(...).filter(...).map(...).forEach(...)
Related Rants
-
justamuslimguy20All the stupid date functions where the days range from 1 to 31 but the months range from 0 to 11
-
sudo-woodo16Whatever the fuck Python's ternary operator syntax is supposed to be.
-
Root18Most hated language features? PL/SQL: • it exists XSLT: • it also exists PHP: • it still exists. VB:...
The forEach in JavaScript makes no sense. It looks like a map /filter/reduce but doesn’t actually return the array. Can you please loop like a normal language?
rant
wk229