Inside self-invoking anonymous function eg:
function() {
....
}()
All variables remain inside it and do not attach themselves to global object or window
. Using that technique, there are patterns created such as module/singleton pattern.
Notice that in JS, variables have function-level scope.