A few things...
- The first is creating an anonymous function and then assigning it to a non anonymous member...
- The second is actually declaring the function, and declared functions are always hoisted
To add to your confusion.. this is what hoisting means... declared functions are "hoisted" to the top so the following is valid.
//call it
funcOne();
//declare it
function funcOne() {
alert("Why am I working? I thought javascript was top down?!?!?");
}
Also, you can name function expressions (for the purpose of calling them recursively). This is also valid
var funcOne = function internalName() {
internalName();
};
I usually prefer creating functions via assignment/expression, mainly because it more accurately describes that functions are first class values, and does not incidentally create possible confusion via hoisting behavior.