Difference between function expression and function decleration?

I dont quite understand what is the difference between these thow and when should I use witch? Im a complete beginner so I would appriciate it if someone can explain to me in a very simple way

At this point in your learning it is safe to accept that they are both the same. There is no one right way to write functions, so whatever your lessons show, just go along with it.

var myFunc = function () {


function myFunction() {


Both have a name, or identifier, both have a function keyword, both have a parameter list, both have a code body. The one written with the equal sign is a function expression, and as an assignment will get a semi-colon at the end. What goes inside them is the same–code statements that we wish to be able to execute over and over whenever we wish.


I came here with the same question… kinda confusing when you hit this lesson in the curriculum. Thank you for this answer!

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.