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.

Example of how functions work in JavaScript for complete beginners

Example of how functions work in JavaScript for complete beginners

Okay, so we've seen how we can write a function, how it can take an input and return an output, and then we can call the function to see the result. Interesting to note here, console.log, log is a function that we're executing. We're actually calling two functions here, the log function, which logs this result into our terminal so that we can see it, and this result is a value returned by this function. In a way, we're actually nested, We actually have nested functions here. I just want to point that out to you. Pretty interesting. So when I say that this is a method, .log is actually a function that's stored as an object for this method console that we access with .notation. So what do I mean by that? Well, functions don't have to just return numbers. They can return strings. They can even return arrays or objects. And we're going to dive deeper into what arrays and objects are in the next lesson, because it's very important that you have a solid understanding of that with…

Contents