开发者

"For" loop better alternative

开发者 https://www.devze.com 2023-02-05 12:18 出处:网络
Having too many many \"For\" loop in my code increase complexity to my development, is there a better开发者_开发问答 solution to For loop 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.


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.


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消