Skip to content

Instantly share code, notes, and snippets.

@sankage
Created April 3, 2012 18:07
Show Gist options
  • Save sankage/2294271 to your computer and use it in GitHub Desktop.
Save sankage/2294271 to your computer and use it in GitHub Desktop.
CoffeeScript: self executing anonymous functions
# Is there a coffeescript way of doing this?
(function($, exports){
# doing random stuff here
})(jQuery, window);
# Other than this:
( ($, exports) ->
# doing random stuff here
)(jQuery, window)
# no syntactic sugar, but you can do:
do ($ = jQuery, exports = window) ->
# doing random stuff here
@davidcelis
Copy link

 do ($, exports) ->
  //stuff

@sankage
Copy link
Author

sankage commented Apr 3, 2012

Ah, but what do $ and exports represent? They are missing the other half of their aliases.

@delijah
Copy link

delijah commented Jul 16, 2014

+1

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