Quantcast
Channel: Possible antipattern: looping until a search condition is met - Code Review Stack Exchange
Browsing all 5 articles
Browse latest View live

Image may be NSFW.
Clik here to view.

Answer by konijn for Possible antipattern: looping until a search condition...

Possible anti-pattern is quite an understatement. There is so much wrong with this that I had to get creative to get over it.The suggestion by @dusky are excellent on how to fix it, but I did not feel...

View Article



Answer by Guffa for Possible antipattern: looping until a search condition is...

One reason would be performance. Normally performance shouldn't be much of an issue until it's actually a problem, but loops are where performance degrades quickly.The performance impact will of course...

View Article

Answer by tim for Possible antipattern: looping until a search condition is met

I know it's not the easiest to read - but is there any reason why I should not be doing it this way?You answered your own question already. It's not easy to read, which is a very good reason not to do...

View Article

Answer by dusky for Possible antipattern: looping until a search condition is...

Readability is very important. You're code does a simple thing but it takes time to actually understand what it's doing.Isn't that easier to read?function findFirst(array, filterFunc) { var length =...

View Article

Possible antipattern: looping until a search condition is met

Whenever I write a loop, I always use closure if it's appropriate by way of a self-executing anonymous function. I will typically write my searching loops as follows:var i = 0, length = myArr.length,...

View Article

Browsing all 5 articles
Browse latest View live




Latest Images