Selvopkaldende anonym funktion tildelt den yournamespacechoice
globale variabel. Serverer effekten af at holde alle funktioner og variabler private for denne funktion. For at eksponere en funktion eller variabel skal vi eksplicit returnere den i bunden af funktionen. Remaps jQuery til $.
var yournamespacechoice = (function ($) ( var publicfunction; function privatefunction() ( // function only available within parent function ) publicfunction = function publicfunction() ( // public function available outside of this funtion ); // Expose any functions that we need to access outside of this scope. Use yournamespacechoice.functionName() to call them. return ( publicfunction: publicfunction ); )(window.$));