Menu
Forums
New posts
Search forums
Members
Current visitors
Log in
Register
What's new
Search
Search
Search titles only
By:
New posts
Search forums
Menu
Log in
Register
Install the app
Install
Forums
Archive
Archive
Javascript
defining functions
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Reply to thread
Message
[QUOTE="Thomas 'PointedEars' Lahn, post: 5012166"] Depending on what you mean by "their definitions", the second sentence may be wrong. For the following is certainly possible: function x(y) { console.log(y); } var z = x; var o = { p: x }; (function(f) { return f; })(o.p)(42); You would be correct if you said that a function declaration cannot appear right-hand side of an assignment operator or within an argument list of a function call. That is so simply because the parser is in Expression context there, and the FunctionDeclaration syntax is considered to be a named FunctionExpression there. In Microsoft JScript, which you mistakenly and misguidingly referred to as "IE", at least in version 5.6.6626, Function instances have no `name' property in any case. ^^^^^^^^ I beg your pardon? Utter nonsense. That is oversimplifying talk; nothing is "hoisted" here. What really happens is that all declarations in source code are specified to happen before control reaches the first statement of the execution context. Variable instantiation adds a property to the ES 1 to 3 Variable Object, with the identifier of the variable or function as name [1]. In ES 5.x, this is described as Declaration Binding Instantiation, i. e. bindings added to a VariableEnvironment's Environment Record, instead, but it follows essentially the same pattern [2]. I strongly suggest that you stop believing blindly in what book authors (anyone, really) say and start thinking for yourself. /Sapere aude!/ HTH PointedEars ___________ [1] Standard ECMA-262, "ECMAScript Language Specification", Edition 3 Final, section 10.1.3, "Variable Instantiation". Ecma International, Geneva, March 2000. [2] Standard ECMA-262, "ECMAScript Language Specification", 5.1 Edition, section 10.5, "Declaration Binding Instantiation". Ecma International, Geneva, June 2011. [/QUOTE]
Verification
Post reply
Forums
Archive
Archive
Javascript
defining functions
Top