Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!texta.sil.at!newsfeed01.chello.at!newsfeed.arcor.de!newsspool4.arcor-online.net!news.arcor.de.POSTED!not-for-mail Content-Type: text/plain; charset="ISO-8859-1" Message-ID: <1936012.sfFm3fLmJ7@PointedEars.de> From: Thomas 'PointedEars' Lahn Reply-To: Thomas 'PointedEars' Lahn Organization: PointedEars Software (PES) Date: Sat, 05 Nov 2011 14:46:12 +0100 User-Agent: KNode/4.4.11 Content-Transfer-Encoding: 7Bit Subject: Re: defining functions Newsgroups: comp.lang.javascript References: <4eb4a8de$0$28686$a8266bb1@newsreader.readnews.com> Followup-To: comp.lang.javascript MIME-Version: 1.0 Lines: 31 NNTP-Posting-Date: 05 Nov 2011 14:46:13 CET NNTP-Posting-Host: 586e749e.newsspool1.arcor-online.net X-Trace: DXC=HeYJ>_k7G:Dk:C4l9A;OcOic==]BZ:afN4Fo<]lROoRA<`=YMgDjhgBD^`i3[QQ=STK X-Complaints-To: usenet-abuse@arcor.de Xref: x330-a1.tempe.blueboxinc.net comp.lang.javascript:8037 Richard Cornford wrote: > Denis McMahon wrote: >> [FunctionExpression vs. FunctionDeclaration] > > In terms of this style of function call there is no advantage of one > over the other. > > The advantages of one over the other are that the function declaration > is less code to write and the actual creation of the function object > will occur unconditionally upon entering the execution context in which > the declaration occurs. Assigning a function expression to a variable is > necessary if the function is to be created conditionally. To be precise, it is necessary to use a /FunctionExpression/ if the function is to be defined in a /Block/ statement. Although several ECMAScript implementations, among them JavaScript 1.3, JScript 3.1.3510, JavaScriptCore 525.13, Opera ECMAScript 5.02, and KJS 3.5.9, include(d) proprietary support for /FunctionDeclaration/ in a /Block/ statement (termed and dealt with as a "function statement"), such code is not portable and therefore best avoided. (Note that the braces of /Block/ statements are easily confused with the braces of a /FunctionBody/; this restriction and recommendation does _not_ apply to the latter.) PointedEars -- Anyone who slaps a 'this page is best viewed with Browser X' label on a Web page appears to be yearning for the bad old days, before the Web, when you had very little chance of reading a document written on another computer, another word processor, or another network. -- Tim Berners-Lee