Self-invoking Anonymous Function - IIFE

A slef-invoking anonymous function is to make sure we stay out of the gloabl scope so that our script can play nicely with others. This is useful/needed when all you javascript code is in one main file.

We can do this by wrapping the code we write or execute within a selfinvoking anonymous function. We create a self incoking anonymous function like this:

(function() {
})();

Now, whatever we put inside of here will only be unique to this anonymous function. It won’t interfere with anything outside of it. So now we can safely create new variables and new functions and we don’t have to worry about our code overriding another variable or function from another script or whatever else may be in teh global scope.

Please note that this site and the posts on it are, and will always be, a work in progress. If i waited for perfection, i’d never get anything done.
A project of 29 CONCEPTS SMC-PVT LTD. Created with by Aamnah. All content is licensed under Creative Commons CC BY-SA 4.0