Everywhere possible, this is the preferred style:
function foo() {
}
With this, you get function names in the fewest possible characters, there's only one caveat:
if (thing) {
function foo() {
}
}
is invalid javascript.
Function declaration syntax are only valid at the top indentation of a function
(function racerJS(){
function valid() {
...
function alsoValid() {
if (something) {
function NOT_VALID() {
}
var butImValid = function butImValidF() {
};
}
}
}
})()
If you are not at the top indentation of a function block, or at the top of a <script> you should use this syntax:
var foo = function fooF() {
};
Notice the function name is fooF
the F
is important for avoiding errors in oldIE, it's easy and you should do it so you don't have headaches getting your JS to run in IE