When I run the following piece of JS code:
var x = (function () {
console.log('Hello x!');
});
var y = function () {
console.log('Hello y!');
};
var z = (function () {
console.log('Hello z!')
return 2;
})();
x();
y();
The following output is printed on the browser's console:
Hello z!
Hello x!
Hello y!
Why "Hello z!" is printed before "Hello x!" & "Hello y!". And how does the Immediately Invoked Function Expression (IIFE) interact with the 'z' variable?
P.S. : I am a beginner.