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

Functions in README #1

Closed
davidchase opened this issue Aug 16, 2014 · 5 comments
Closed

Functions in README #1

davidchase opened this issue Aug 16, 2014 · 5 comments

Comments

@davidchase
Copy link

When declaring a function, always use the function expression form instead of function declarations.

Yet underneath you show that var foo = function(){}; is bad whilefoo function(){}; is good

I thought function expression is the storing of anonymous or named functions in a variable and function declaration is a named function without a variable assignment.

@bevacqua
Copy link
Owner

Function expression is an anon function, named func expr is a named function and func declaration is the var foo form

@theborakompanioni
Copy link

@bevacqua That is definitely not right. The "var foo form" is a function expression.

@bevacqua
Copy link
Owner

Should be more accurate after 6dfed02

@davidchase
Copy link
Author

👍 for the fix, but i still prefer function expressions var foo = function(){} like you say always declare function on top of scope, that way your using them only after they have been created 😄

@bevacqua
Copy link
Owner

Yeah, that's fine too, but using declarations you won't have to remember to put them before things that need to execute the function

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

No branches or pull requests

3 participants