I'm wondering about named function expressions in javascript, specifically node.
Is there any reason to avoid the following?
var foo = function foo () {};
I really like using function expressions for code organization but I really like function declarations for stack traces. As far as I can tell the above code works, but it just doesn't look right.
Can anyone provide any insight?
ABE: I'm specifically looking for the instance where you are naming a function the same as the variable you are assigning it to.
Function declarations come with the added baggage that you have to have internal functions defined prior to their use in order to avoid jslint warnings and hence your code tends to read last to first which I'm not a fan of.
To get around this you can use function expressions, define your vars at the top and then order your code more or less in the order it is run. However, going this route means your functions are all anonymous unless you name them. Which brings us back to the original question.
Can I name a function declaration that is being assigned to a varable the same as the variable itself.