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


Groups > comp.lang.javascript > #8037

Re: defining functions

Message-ID <1936012.sfFm3fLmJ7@PointedEars.de> (permalink)
From Thomas 'PointedEars' Lahn <PointedEars@web.de>
Organization PointedEars Software (PES)
Date 2011-11-05 14:46 +0100
Subject Re: defining functions
Newsgroups comp.lang.javascript
References <4eb4a8de$0$28686$a8266bb1@newsreader.readnews.com> <ZeWdnYj57omGICnTnZ2dnUVZ8t2dnZ2d@giganews.com>
Followup-To comp.lang.javascript

Followups directed to: comp.lang.javascript

Show all headers | 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