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 ArticleAnswer 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 ArticleAnswer 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 ArticleAnswer 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 ArticlePossible 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
More Pages to Explore .....