Functions

Functions as Values

Functions as Values

A function name can be used as a value. If you store the function without parentheses, the new variable refers to the same callable function.

Read this code:

js
function welcome(name) {
  return "Welcome, " + name;
}

const savedWelcome = welcome;
const message = savedWelcome("Mira");

Your task: Predict the type of savedWelcome and the value stored in message.

Free with a JS Exercises account

Sign in to start coding, run your solution, and keep your progress saved for later. No payment needed.

By continuing, you agree to our Terms and Privacy Policy. We'll send occasional product updates and news. You can unsubscribe anytime.

Functions as Values

A function name can be used as a value. If you store the function without parentheses, the new variable refers to the same callable function.

Read this code:

js
function welcome(name) {
  return "Welcome, " + name;
}

const savedWelcome = welcome;
const message = savedWelcome("Mira");

Your task: Predict the type of savedWelcome and the value stored in message.

Free with a JS Exercises account

Sign in to start coding, run your solution, and keep your progress saved for later. No payment needed.

By continuing, you agree to our Terms and Privacy Policy. We'll send occasional product updates and news. You can unsubscribe anytime.

Console

Run code to see output.