F
FAQ server
-----------------------------------------------------------------------
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/
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/