Variables declared in the self executing function only exists within the scope of self executing function and not outside of it. so you can decare and write code without worring of it’s effect on other blocks of code.
Also this type of function is only effective if you wish to run it only once on document ready. Here are the two ways self executing function can be declared.
(function() {
var v = ... // this variable can be used in the self executing function but not from outside
})();
or
(() => {
var v = ... // this variable can be used in the self executing function but not from outside
})();