For my example code below, the use of traditional named functions and anonymous functions perform the same task.
I've read var functionName = function() {} vs function functionName() {}, and understand how the first named function is defined at run-time, whereas the second anonymous function is defined at parse-time for a script block.
My question is specifically what conditions would make one approach more suitable than the other?
function get1() {
return 'Hello';
};
function alert1(data) {
alert(data);
};
var get2 = function() {
return 'Goodby';
};
var alert2 = function(data) {
alert(data);
};
alert1(get1());
alert2(get2());