Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.javascript > #8037

Re: defining functions

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> (permalink)
From Thomas 'PointedEars' Lahn <PointedEars@web.de>
Reply-To Thomas 'PointedEars' Lahn <cljs@PointedEars.de>
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> <ZeWdnYj57omGICnTnZ2dnUVZ8t2dnZ2d@giganews.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[Q<Q2NDZm8W4\YJNL;?f@h5gMfbLBIlHSWN<J<O0K]AG>Q=STK
X-Complaints-To usenet-abuse@arcor.de
Xref x330-a1.tempe.blueboxinc.net comp.lang.javascript:8037

Followups directed to: comp.lang.javascript

Show key headers only | View raw


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

Back to comp.lang.javascript | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

defining functions Denis McMahon <denismfmcmahon@gmail.com> - 2011-11-05 03:09 +0000
  Re: defining functions "Richard Cornford" <Richard@litotes.demon.co.uk> - 2011-11-05 04:35 +0000
    Re: defining functions Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2011-11-05 14:46 +0100
  Re: defining functions "J.R." <groups_jr-1@yahoo.com.br> - 2011-11-05 19:19 -0200
    Re: defining functions Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2011-11-07 13:26 +0100
      Re: defining functions "J.R." <groups_jr-1@yahoo.com.br> - 2011-11-13 21:39 -0200
        Re: defining functions Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2011-11-14 19:49 +0100
          Re: defining functions "J.R." <groups_jr-1@yahoo.com.br> - 2011-11-14 17:00 -0200

csiph-web