Path: csiph.com!eternal-september.org!feeder.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail From: $Bill Newsgroups: comp.lang.javascript Subject: Re: JSlint finds for loops intolerable Date: Sun, 28 Aug 2016 14:59:16 -0700 Organization: A noiseless patient Spider Lines: 34 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit Injection-Date: Sun, 28 Aug 2016 21:59:25 -0000 (UTC) Injection-Info: mx02.eternal-september.org; posting-host="5b2cab364112ad98b7df59c61a581b22"; logging-data="31052"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/yFxee7QY1mgoEHQjlHDqUM1eKermASE4=" User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.2.0 In-Reply-To: Cancel-Lock: sha1:YwJuXJostgPI4pX+IZSNHg/TBNc= Xref: csiph.com comp.lang.javascript:31197 On 08-28-16 03:56, emf wrote: > In the current JSLint help webpage (http://jslint.com/help.html) it now says: > > "Tolerate for statement: > true if the for statement should be allowed > It is almost always better to use the array methods instead." > > Getting rid of the for loops is a big change. Reflecting on it, however, the for loop is an awkward construction -- it's just something you learn as a matter of fact when you begin and that time on you take it for granted. Instead of > > for (var i = 0; i < 10; i += 1) { > ... > } > > the while loop does seem more straightforward: > > var i = 0; > while (i < 10) { > ... > i += 1; > } > > After stopping using for loops, I can imagine a time when I won't be able to understand why I once almost always preferred to use them. > > I do not understand, however, the comment about array methods. I seldom find use for them. Can someone explain what Crawford implies?? Anyone that's been a programmer prior to HTML is familiar with the standard C for loop. Seems more straightforward than the 3-piece while loop you have there. It's concise, self contained on one line and obvious to any programmer that's been around a while. Combined with a while and a foreach loop, you have all the looping constructs you need. Of course there was no object oriented programming at the time of invention - everything was procedural which could make a difference. So "Tolerate For == true;"