Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IIFE changed to Crockford's prefered format #85

Closed
wants to merge 2 commits into from
Closed

IIFE changed to Crockford's prefered format #85

wants to merge 2 commits into from

Conversation

yitsushi
Copy link

@yitsushi yitsushi commented Oct 9, 2013

IIFE changed to Crockford's prefered format.

The first parenthesis is a marker for an IIFE and there is no need to call the function only for let JavaScript know it will be called immediately.

Some linter warns for it like jshint (http://www.jslint.com/).
"Move the invocation into the parens that contain the function."

Function Declarations part of http://javascript.crockford.com/code.html

  The first parenthesis is a marker for an IIFE
  and there is no need to call the function only
  for let JavaScript know it will be called immediately.
@serbanghita
Copy link

Agree, good catch!

@hshoff
Copy link
Member

hshoff commented Oct 9, 2013

Hey @yitsushi, thanks for checking out our style guide!

This is a style choice. The most important part is consistency.

At Airbnb we prefer !function(){}(); if we're wrapping a module (reasoning). I wrote our style guide's IIFE in the style of (function(){})(); because that was how a lot of IIFEs in our codebase were written.

Feel free to fork the guide and update it with crockford's prefered format! We'd be happy to link to it in the resources.

🍻

@hshoff hshoff closed this Oct 9, 2013
@yitsushi
Copy link
Author

yitsushi commented Oct 9, 2013

+1

:) And jshint (or similar) does not warn you? But, yes I understand :)

@hshoff
Copy link
Member

hshoff commented Oct 9, 2013

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants