-
-
Save GitHub-Mike/55027d81604da9bd39dea0e3194cd552 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// closure pattern | |
( function( window, document, undefined ) { | |
console.log('Hello world!'); | |
})( this,this.document ); | |
// single-lettered minified version | |
(function(w,d,u){console.log('Hello world!');})(this,this.document); | |
// self executing anonymous function | |
(function(){})() | |
// bypassing a var declaration at the top and `this` is always the global object when in global scope | |
(function(myname){})('paul') | |
// switch up the args passed in on all ready functions | |
( function( oReady ) { | |
$.fn.ready = function( fn ) { | |
return oReady.call( this, function() { fn.call( this, $, window, document ); }); | |
}; | |
})( $.fn.ready ); | |
// which enables | |
$(function($,window,document,undefined){ alert(document) }) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment