Answer the question
In order to leave comments, you need to log in
Is there a sequence of calls to self-executing functions in JS?
Good afternoon!
There is a similar piece of code:
(function ($) {
// build new menu markup
var $fn = $('<div />', {id: 'our-unique-id'})
.wrapInner('<div class="inner-wrap"><nav/></div>');
// .. do something with it ..
$fn.appendTo($('body'));
})(jQuery);
(function ($) {
var $el = $('#our-unique-id'); // А НАЙДЕТ ЛИ?
})(jQuery);
Answer the question
In order to leave comments, you need to log in
It will be useful to read about EventLoop in JS. (you can watch the part of the cantor's podcast about nodeJS, it is very well covered there)
Asynchronous functions are queued, where they are executed when the interpreter is free.
But in your case, the functions are synchronous, so it should execute
>> Given the asynchrony of JS, I can assume that both functions will run simultaneously in some situation and the second one will request the element when the first one has not yet physically created it.
Where do you have asynchrony in the code of the first IIEFE?
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question