Re: [JSMentors] Edge cases with function declarations

2011-03-17 Thread Peter van der Zee
On Wed, Mar 16, 2011 at 4:05 PM, shaun shaun.ether...@gmail.com wrote: I think i read in the Google Javascript style guide that for situations like the one above, functions should be declared like: var f = function... I guess this is so var hoisting does the right thing for you? No. I

Re: [JSMentors] Edge cases with function declarations

2011-03-17 Thread shaun etherton
On Thu, Mar 17, 2011 at 6:23 PM, Peter van der Zee jsment...@qfox.nlwrote: When you want to create functions depending on some factor (so inside an if), as far as the specification goes, you can only use function expressions (var f = function ...). So, recap: function f(){} // var f is

[JSMentors] Edge cases with function declarations

2011-03-16 Thread Bruno Jouhier
I found difference between JS engines in the way they handle code like the following: (function() { foo(m1a); function foo(m) { alert(f1: + m); } foo(m1b); if (true) { foo(m2a); function foo(m) { alert(f2: + m); } foo(m2b); } foo(m3a); function foo(m) { alert(f3: +

Re: [JSMentors] Edge cases with function declarations

2011-03-16 Thread Peter van der Zee
On Mon, Mar 14, 2011 at 12:06 PM, Bruno Jouhier bjouh...@gmail.com wrote: Is this behavior precisely defined by the ECMAScript standard, or is it left open to interpretation? Enter Yuri or Dmitry ;) The simple answer is that yes, the ECMA standard specifically specifies that function

Re: [JSMentors] Edge cases with function declarations

2011-03-16 Thread shaun
On 14/03/11 9:36 PM, Bruno Jouhier wrote: I found difference between JS engines in the way they handle code like the following: (function() { foo(m1a); function foo(m) { alert(f1: + m); } foo(m1b); if (true) { foo(m2a); function foo(m) { alert(f2: + m); } foo(m2b);