No reason is stated for why "always favor function declaration over function express"
mocheng opened this issue · comments
Here https://github.com/bevacqua/js#functions .
IMHO, function declaration is preferred since it is easy for debugging.
Because hoisting
Sorry, but can you be more clear?
Do you mean function express is bad in below case?
foo(); // foo is undefined here
var foo = function() {
}
function declaration always works
foo(); // foo is a function here
function foo() {
}
Yeah, that's what I mean. Since expression assignment doesn't get hoisted, it's inherently worse than using a function declaration instead