Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trial
Josh Hicks
14,146 PointsCan someone please explain what a function expression is in simple terms?
I'm having trouble finding the difference between a "declared function" and a "function expression". As far as I can see the only difference is that one can have functions passed as arguments, and that one might be stored in a variable. What am I not getting here?
1 Answer
David Smith
21,220 Pointsfunction declarations are parsed at pre-execution stage when the brower prepares to execute the code. Can be called before and after the definition
function expressions are are created when the execution flow reaches them. so in other words function expressions can only be used AFTER they are executed
I have found two articles that explain these concepts very well
http://javascript.info/tutorial/functions-declarations-and-expressions http://stackoverflow.com/questions/336859/var-functionname-function-vs-function-functionname