3 ms·
The main point of the article seems to be that the JavaScript for construct is exactly the same as the C for construct. You get the same power, the same freedom
by Swizec 16y ago
The main point of the article seems to be that the JavaScript for construct is exactly the same as the C for construct. You get the same power, the same freedom and the same responsibility to for the love of god use something better.
Especially in JavaScript. Please stop using for loops in favour of asynchronous recursion (or similar). Thank you.
This is what I've been using lately, pretty neat: http://github.com/caolan/async http://github.com/caolan/async
- angusC 16y agoHi Swizec - maybe the article could have been clearer - the real point was this: now that our standard iteration pattern has made obsolete by higher order functions (forEach, filter, map etc. - which are available natively as well as github :-)) lets see if we can re-purpose it for fun and learning. It wasn't supposed to be taken too seriously. BTW for-loops are not exactly the same in C, because JavaScript has no block scope.
- gcb 16y agoi believe his point (or i liked to read it such as) was more towards the responsibility of not messing up other programmers head, just because the language gives you the power to do so. should the next programmer (usually =you+T) see the loop and think "oh, a loop" or "oh, a loop. and it uses the assignment of the each var to the conditional block... great, now i will have to go through the data we receive to make sure no element get's a value of zero"
- Swizec 16y agoI know I know, I've done some pretty horrible things with for loops myself. :) Just fell like it's important to state that one shouldn't use "fun and learning" techniques in a production environment.