I'm joking with Javascript and I came across a question. I understand that when my HTML page loads, if I already want to execute a function without having to declare it, I just have to define this direct function, like this:
(function(){console.log('foo');})();
My question (because I could not make it work) is how I can perform a double function in the same statement, something like this (in my understanding):
(
function(){
var b = 'hello world!';
console.log('bar');
},
function(b){
console.log('foo ' + 'b'); //o "b" declarado anteriormente na 1ª função
}
)();
Is there something like this? basically I want this function to execute after the first but that this second consumes the same effort as the DOM ...