Hacker News new | ask | show | jobs
by nkozyra 4836 days ago
I don't think that's what he's addressing, though.

It's this:

var foo = function() { redeclaration(); }

that I believe he's referring to, unless I'm mistaken.

1 comments

I don't believe so. It sounds like he prefers using function declations to function expressions. And this is incorrect according to most js gurus. For example:

http://javascriptweblog.wordpress.com/2010/07/06/function-de...

From that link:

"b) Function Expressions are more versatile. A Function Declaration can only exist as a “statement” in isolation. All it can do is create an object variable parented by its current scope. In contrast a Function Expression (by definition) is part of a larger construct. If you want to create an anonymous function or assign a function to a prototype or as a property of some other object you need a Function Expression. Whenever you create a new function using a high order application such as curry or compose you are using a Function Expression. Function Expressions and Functional Programming are inseparable."

Also this link: http://kangax.github.com/nfe/

brings up these disadvantages to function declarations:

* can't conditionally declare functions with consistent results across browsers * function declarations cannot appear in blocks (technically), though many implementations allow this in practice

finally, i'd argue that function expressions encourage you to think of functions as the first class objects js intended them to be

He included far more code than was necessary, if that's the case. I don't see why the implementation of the function expression would be relevant if so. Clarity would help here.