Edit added 2+ years later
I "checked" the @dandavis answer because it answers my original question, giving reasons to prefer const foo
. However, I am completely convinced by the @Wayne Bloss answer that function foo()
is generally superior.
Original Question here
For example, in this Redux video, the instructor always uses syntax like
const counter = (state=0, action) => {
... function body here
}
where I would just use the "traditional"
function counter(state=0, action) {
... function body here
}
Which is actually shorter and, IMO, clearer. It's easier to scan the fairly even and structured left edge of the page for the word "function" than scan the raggedy right edge for a small "=>".
Other than this
, and trying to be objective, not opinion, is there some useful difference or advantage to the newfangled syntax?
const
helps ensure the function doesn't get redefined later on.