Is there a downside in extracting or checking all members in a function?

I was just thinking if there's a downside doing recursion, or checking all the values of an array for a certain value. For example, we have Battle Members or Party members. 

$gameParty.battleMembers()If I want to check if anyone of them has this or that, I'd have to use a for loop, extract each member and then do an if statement saying that if this current index member has this state, then do this.

Is making a loop, checking each value and then doing a condition has a downside? Are there specific or a more professional approach in checking?
I was just thinking if there's a downside doing recursion, or checking all the values of an array for a certain value. For example, we have Battle Members or Party members. 

$gameParty.battleMembers()If I want to check if anyone of them has this or that, I'd have to use a for loop, extract each member and then do an if statement saying that if this current index member has this state, then do this.

Is making a loop, checking each value and then doing a condition has a downside? Are there specific or a more professional approach in checking?
why not do:

$gameParty.battleMembers().forEach(something) { ... }then:

Code:
{ return something.doesIhaveCheeseBurger() }
loops are fast, simplest, and most versatile, so try that first. you can break out of it early when you find the match. foreach and map are limited in application and performance of the browsers' implementations of them is questionable, and you can't break out of them early.


there are no downside doing recursion if done correctly. in fact, recursion can be many times faster than loops if done properly. but in your case, i don't see why you need recursion.
it doesn't sound like you need recursion though .

Original thread: https://forums.rpgmakerweb.com/threads/is-there-a-downside-in-extracting-or-checking-all-members-in-a-function.50270/