From the course: Master Next.js: Elaborate Hands-On Web Development, React Basics, Advanced Next.js, and Deployment

Unlock this course with a free trial

Join today to access over 25,200 courses taught by industry experts.

What are function expressions in JavaScript?

What are function expressions in JavaScript?

Okay, so we've covered declarative functions. Now, we've looked at writing a function, adding an input with number to create the area of a square. We looked at changing objects with functions, which is very powerful. The next thing I want to discuss is this isn't the only way to write functions. We're writing functions here as statements. But you can also write functions as expressions. So what we're going to do is we're going to create a new file. And let's call this function-expressions.js and we can create that file and by the way in the terminal now I'm going to type in clear and when I do that it should clear out all of that clear up all of this top stuff here so we have a nice fresh slate. All right I'll push the terminal down for now and we're going to learn, I'll bring in my comments here, learn about function expressions. So So we can start off by saying a function expression can be anonymous and does not need to have a name. So how would we write that? How do you write a…

Contents