Proyb2
Proyb2

Reputation: 993

"For" loop better alternative

Having too many many "For" loop in my code increase complexity to my development, is there a better solution to For loop alternative?

In my code. I have used 50% of the time to loop array.

Upvotes: 0

Views: 251

Answers (2)

Mathias
Mathias

Reputation: 2724

Well if you have to work on Arrays alot check the reference under Array. They have very usefull functions like Array.every() or Array.forEach() or Array.map().

Maybe one of those is helpful to your concern.

Upvotes: 1

Matt
Matt

Reputation: 1422

Well, there's for each and while, but they're still loops!

Sometimes, looping is just necessary, and there's no way around it. Can you explain more about what you think is wrong with your current code, or perhaps post a code sample?

On the contrary, if you use the same loop style throughout the application, it may make it easier to read for third parties.

Upvotes: 0

Related Questions