Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!aioe.org!.POSTED!not-for-mail From: "J.R." Newsgroups: comp.lang.javascript Subject: Re: Difference between findPos("divThis") and findPos(divThis) Date: Mon, 14 Nov 2011 14:14:50 -0200 Organization: Aioe.org NNTP Server Lines: 30 Message-ID: References: <4775241.ypaU67uLZW@PointedEars.de> <2394720.ArG6xLiZAS@PointedEars.de> <4ec07ef1$0$28711$a8266bb1@newsreader.readnews.com> <4ec11fb1$0$28605$a8266bb1@newsreader.readnews.com> NNTP-Posting-Host: edb3lPNLwDIT/BKKc/Xuzw.user.speranza.aioe.org Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Complaints-To: abuse@aioe.org User-Agent: Mozilla/5.0 (Windows NT 6.0; rv:8.0) Gecko/20111105 Thunderbird/8.0 X-Notice: Filtered by postfilter v. 0.8.2 Xref: x330-a1.tempe.blueboxinc.net comp.lang.javascript:8319 On 14/11/2011 12:03, Denis McMahon wrote: > On Mon, 14 Nov 2011 03:14:20 -0200, J.R. wrote: > >> The advantages of using the Single var Pattern at the top of your >> functions are: > > I'm not objecting to the suggestion that best practice includes defining > all your variables with var statements at the start of a function. I > agree that this is indeed best practice. > > I am, however, objecting to (a) your assertion that it "must" be done, or > (b) that best practice requires the use of a single var statement. You are right, I should have not used the "must not" as it expresses prohibition in English, and a code pattern is not necessarily one of the "best coding practices", although, in many cases, they seem to walk hand in hand. And sticking to a strict coding style is usually considered one of the best practices in many programming languages. Examples of "best practices" in JS: The above link is propped up by the Mozilla Developer Network , and there are other pages at MDN concerning to best practices in other aspects of development (extensions, security, ect.). Cheers, Joao Rodrigues (J.R.)