Yahoo India Web Search

Search results

  1. Syntax. return value; Parameters. More Examples. Calculate the product of two numbers and return the result: // Call a function and save the return value in x: var x = myFunction (4, 3); function myFunction (a, b) { // Return the product of a and b. return a * b; } Try it Yourself » Related Pages. JavaScript Tutorial: JavaScript Functions.

    • Syntax
    • Example 1: Returning A Single Value
    • Example 2: Returning Multiple Values Using An Object

    value: The value returned to the function caller. It is an optional parameter. If the valueis not specified, the function returns undefined

    This code defines a function Product(a, b) that takes two parameters a and b. It returns the product of a and b by multiplying them. Then, it calls the `Product()` function with arguments 6 and 10 and logs the result, which is 60.

    Here, the code defines a function Language() that returns an object containing three properties: first, second, and Third, each storing a string value. Then, it uses object destructuring to assign these properties to variables first, second, and Third. Finally, it logs the values of these variables.

  2. Aug 11, 2023 · js. return ( . a + b. ); Examples. Interrupt a function. A function immediately stops at the point where return is called. js. function counter() { // Infinite loop for (let count = 1; ; count++) { . console.log(`${count}A`); // Until 5 if (count === 5) { return; } .

  3. Jan 21, 2020 · JavaScript Return Statements. Introduction. When a return statement is called in a function, the execution of this function is stopped. If specified, a given value is returned to the function caller. If the expression is omitted, undefined is returned instead. return expression; Functions can return:

  4. Jul 25, 2024 · Return values are just what they sound like — the values that a function returns when it completes. You've already met return values several times, although you may not have thought about them explicitly. Let's return to a familiar example (from a previous article in this series):

  5. Jun 19, 2017 · Syntax. return [[expression]]; . expression. The expression whose value is to be returned. If omitted, undefined is returned instead. Description. When a return statement is used in a function body, the execution of the function is stopped. If specified, a given value is returned to the function caller.

  6. People also ask

  7. The return statement signifies the end of a function and returns a particular value to the function’s caller. Once the function’s code reaches the return statement, it stops executing and returns the result to the caller. Every other code written after this value in the function will be unreachable.