Return Value (JavaScript)

Functions may or may not return a response value when they are called.

What is a return value?

Functions may or may not return a response value when they are called. When a function returns a response this is called a return value;

Functions with NO return value can be defined like this

function sayHello() {
    console.log('Hello');
    // return is implied
}

function sayHello() {
    console.log('Hello');
    return; // the return is explicit
}

Functions that return a value must always explicity specify the return

function add(first, second) {
    return first + second;
}

Level: Apprentice · More JavaScript terms at this level

Updated