From: FAQ server on 23 May 2010 19:00 ----------------------------------------------------------------------- FAQ Topic - What is a function statement? ----------------------------------------------------------------------- The term function statement has been widely and wrongly used to describe a ` FunctionDeclaration `. This is misleading because in ECMAScript, a ` FunctionDeclaration ` cannot appear as a Statement. To add to this confusion, some implementations, notably Mozillas', provide a syntax extension called function statement. This is allowed under section 16 of ECMA-262, Editions 3 and 5. Example of function statement (nonstandard): // Nonstandard syntax, found in GMail source code. DO NOT USE. try { // FunctionDeclaration not allowed in Block. function Fze(b,a){return b.unselectable=a} /*...*/ } catch(e) { _DumpException(e) } Implementations that have the function statement extension process ` Fze ` as a Statement, in order, while other known implementations evaluate ` Fze ` upon entering the execution context that it appears in. For consistent behavior across implementations, avoid function statement; use either ` FunctionExpression ` or ` FunctionDeclaration ` instead. Example of ` FunctionExpression ` (valid): var Fze; try { Fze = function(b,a){return b.unselectable=a}; /*...*/ } catch(e) { _DumpException(e) } Example of ` FunctionDeclaration ` (valid): // Program code function aa(b,a){return b.unselectable=a} http://jibbering.com/faq/example/functionStatement.html https://mail.mozilla.org/pipermail/es-discuss/2008-February/005314.html http://groups.google.com/group/comp.lang.javascript/msg/aa9a32d0c6ae0342 http://groups.google.com/group/comp.lang.javascript/msg/3987eac87ad27966 http://nanto.asablo.jp/blog/2005/12/10/172622 (Article in Japanese) The complete comp.lang.javascript FAQ is at http://jibbering.com/faq/ -- The sendings of these daily posts are proficiently hosted by http://www.pair.com.
From: kangax on 23 May 2010 19:58 On 5/23/10 7:00 PM, FAQ server wrote: > ----------------------------------------------------------------------- > FAQ Topic - What is a function statement? > ----------------------------------------------------------------------- > > The term function statement has been widely and wrongly used to > describe a ` FunctionDeclaration `. This is misleading because in > ECMAScript, a ` FunctionDeclaration ` cannot appear as a Statement. > To add to this confusion, some implementations, notably Mozillas', provide > a syntax extension called function statement. This is allowed under > section 16 of ECMA-262, Editions 3 and 5. MDC, unfortunately, doesn't describe Mozilla's function statements very well, so I did it in NFE article, for anyone interested � <http://yura.thinkweb2.com/named-function-expressions/#function-statements> Curiously, older Safari (<=3.0.4) and some versions of Blackberry browser implement function statements identically to Mozilla's extension. [...] -- kangax
From: Thomas 'PointedEars' Lahn on 23 May 2010 20:03 kangax wrote: > On 5/23/10 7:00 PM, FAQ server wrote: >> ----------------------------------------------------------------------- >> FAQ Topic - What is a function statement? >> ----------------------------------------------------------------------- >> >> The term function statement has been widely and wrongly used to >> describe a ` FunctionDeclaration `. This is misleading because in >> ECMAScript, a ` FunctionDeclaration ` cannot appear as a Statement. >> To add to this confusion, some implementations, notably Mozillas', >> provide a syntax extension called function statement. This is allowed >> under section 16 of ECMA-262, Editions 3 and 5. > > MDC, unfortunately, doesn't describe Mozilla's function statements very > well, so ... .... you should edit it. PointedEars -- Use any version of Microsoft Frontpage to create your site. (This won't prevent people from viewing your source, but no one will want to steal it.) -- from <http://www.vortex-webdesign.com/help/hidesource.htm> (404-comp.)
From: Garrett Smith on 24 May 2010 03:45 On 5/23/2010 4:00 PM, FAQ server wrote: > ----------------------------------------------------------------------- > FAQ Topic - What is a function statement? > ----------------------------------------------------------------------- > > The term function statement has been widely and wrongly used to > describe a ` FunctionDeclaration `. New FAQ Topic idea: | What is a FunctionDeclaration? ?
From: Dmitry A. Soshnikov on 24 May 2010 03:48
On 24.05.2010 3:58, kangax wrote: > On 5/23/10 7:00 PM, FAQ server wrote: >> ----------------------------------------------------------------------- >> FAQ Topic - What is a function statement? >> ----------------------------------------------------------------------- >> >> The term function statement has been widely and wrongly used to >> describe a ` FunctionDeclaration `. This is misleading because in >> ECMAScript, a ` FunctionDeclaration ` cannot appear as a Statement. >> To add to this confusion, some implementations, notably Mozillas', >> provide >> a syntax extension called function statement. This is allowed under >> section 16 of ECMA-262, Editions 3 and 5. > > MDC, unfortunately, doesn't describe Mozilla's function statements very > well, so I did it in NFE article, for anyone interested � > <http://yura.thinkweb2.com/named-function-expressions/#function-statements> > > Yep, as addition an appropriate section from my article: <http://dmitrysoshnikov.com/ecmascript/chapter-5-functions/#feature-of-named-function-expression-nfe> with all consequences for some SpiderMonkey versions: <http://dmitrysoshnikov.com/ecmascript/chapter-5-functions/#nfe-and-spidermonkey> and JScript: <http://dmitrysoshnikov.com/ecmascript/chapter-5-functions/#nfe-and-jscript> Dmitry. |