Skip to content

Instantly share code, notes, and snippets.

@rwaldron
Created April 28, 2011 14:18
Show Gist options
  • Save rwaldron/946432 to your computer and use it in GitHub Desktop.
Save rwaldron/946432 to your computer and use it in GitHub Desktop.
Running collection of IIFE Patterns
(function( window, document, undefined ){
})( this, this.document );
(function( global, undefined ){
})( this );
// miketaylr
(function( win, doc ){
// SCREW U UNDEFINED
})( window, document );
// ralphholzmann
(function poll() {
/* Lots of stuffs here */
if ( cssIsReady ) {
cssCallback();
} else {
setTimeout( poll, 50 );
}
})();
// mennovanslooten
new function() {
// No arguments though
}
// addyosmani
(function(){
arguments.callee();
}());
(function(){
/* do stuff */
}());
// rmurphey
!function(){
// Note that I don't like this one, but it does exist :)
}();
@rmurphey
Copy link

!function(){ /* ... */ }()

Note that I don't like this one, but it does exist :)

@sindresorhus
Copy link

Here are some more:

null,function(){ /* ... */ }()

this,function(){ /* ... */ }()

666,function(){ /* ... */ }()

'☹',function(){ /* ... */ }()

-function(){ /* ... */ }()

+function(){ /* ... */ }()

|function(){ /* ... */ }()

^function(){ /* ... */ }()

>>>function(){ /* ... */ }()

~function(){ /* ... */ }()

-([[{}||{}]])>>>function(){ /* ... */ }()

None of them should be used though.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment