Let’s stop calling them self-executing functions
This practice is commonly referred to as a “self-executing function” or sometimes “self-invoking”. The function, in this case anonymous, is wrapped in a set of parentheses which contains the scope of its variables within the function, hence protecting them from outside interference. The second set of parentheses trigger the execution of the code contained within the first set. In other words, the first set of parentheses defines the function and the second set immediately executes the function. This syntax is also used to differentiate between function declarations and function expressions.
There’s plenty more we could discuss about this, and even a few alternate syntax examples, but I don’t want to get too far away from my point, which is this is not “self-executing”. The parentheses that execute the function are defined outside the function boundaries. A truly self-executing function would cause itself to execute, which I don’t believe is possible. Recursion is close, but it still couldn’t account for the initial function execution. More accurately, this is an “immediately executed” function.
This post was going to be more long winded but I found a great article aptly titled Immediately-Invoked Function Expression by Ben Alman that does a much better job of explaining the details than I could have. The acronym (IIFE) may be pronounced “iffy”, but there’s no question in my mind it’s the better choice.