Skip to content

Instantly share code, notes, and snippets.

@petrosalema
Created June 22, 2011 10:32
Show Gist options
  • Save petrosalema/1039841 to your computer and use it in GitHub Desktop.
Save petrosalema/1039841 to your computer and use it in GitHub Desktop.
I think it should be best practice to name immediately invoked functions (often anonymous), here's why...
// Execute this and look at your console errors.
// this ...
(function __I_HAVE_A_NAME_NOW__ () {
// deliberate error
catchMeIfYouCan();
})();
// ... debugs far better this anonymous function
(function /* __I_HAVE_A_NAME_NOW__ */ () {
// deliberate error
catchMeIfYouCan();
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment