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

JavaScript

Function expression and function deceleration?

So what's the difference between function expression and function declaration? I'm honestly kinda lost here but feel like I'm just missing a small piece of information to put it together.

Would someone be willing to show me an example and explain? Thank you!

Check out the following link if you haven't figured it out yet! Hopefully this makes it a bit easier to understand.

https://medium.com/@mandeep1012/function-declarations-vs-function-expressions-b43646042052

And just to sum the article up.

A function declaration just starts like: function greet (greetings) {return greetings} and is called with greet() in this case.

A function expression is storing the function inside of a variable and will be called with the variable you stored it in.

1 Answer

That article+ your definition made it very clear, thank you very much!