Search⌘ K
AI Features

Functions

Explore JavaScript functions to understand how return values work, how arguments are handled, and the concept of function hoisting. This lesson helps you grasp function behavior and argument management for effective JavaScript coding.

As you learned in the previous chapter, functions are very important concepts in JavaScript.


In this section, you’ll dive deeper into the implementation of functions and get acquainted with many exciting features that make JavaScript functions powerful.


Function return values

Functions may retrieve results.

  • You can use the return statement to pass back a result.
  • If you specify return with no value, the function will immediately return without a value.
  • If you utilize the result of a function that does not return a value, be prepared that you could get undefined.

The Listing below demonstrates this behavior:

Listing: Using return in various ways in a function

...