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 JavaScript and the DOM (Retiring) Responding to User Interaction Functions as Parameters

"Function statement turned into function expression." Doesn't he mean Function *declaration* into function expression?

So I took the advice of the video and checked out the teacher's notes to better understand the difference between a function statement and a function expression. However the link for "function statement" took me to "function declaration" on MDN. From what I understand, a "function statement" is nothing more than the body of a function - the code between the {} brackets. On the other hand, a function declaration is, well, what we have been using since we first learned functions in the beginning JavaScript courses.

So did I miss something, or did the teacher misspeak? Because it looks like in the video he actually turned a function declaration into a function expression, not a function statement into a function expression like he said.

Of course, to me, the example he was describing didn't look quite like any of the three exactly, but I chalked that up to my own limited experience and based my assumption on what looked closest to a declaration/expression based on what I know and what I just read.

Thank you in advance.

1 Answer

Diana Le
Diana Le
6,794 Points

I think he's using the terminology "function declaration" and "function statement" interchangeably. The MDN documentation also uses the terms this way.

The function declaration (function statement) defines a function with the specified parameters.

I know it's confusing because some resources online will write "statements" as being the body of the function within the curly braces.