The below works as intended
var dogName = function animalName(name) {
console.log("My name is " + name);
}
dogName('Scruffy');
(function () {
console.log("My name is Fido!");
})();
If you comment out dogName('Scruffy'); it outputs this
My name is function () {
console.log("My name is Fido!");
}
If you adjust the IIFE to
(function () {
console.log("My name is Fido!");
}()); // ()) instead of )()
It outputs
My name is Fido!
My name is undefined
Why does the functional expression use the IIFE as it's name variable, and why is the IIFE executed first before the functional expression in the last example?