About 8,640,000 results
Open links in new tab
  1. How to return values in javascript - Stack Overflow

    May 4, 2011 · You can return an array, an object literal, or an object of a type you created that encapsulates the returned values. Then you can pass in the array, object literal, or custom object into a method to disseminate the values. Object example: function myFunction(value1,value2,value3) { var returnedObject = {}; returnedObject["value1"] = value1;

  2. JavaScript return Statement - W3Schools

    // 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; }

  3. assign function return value to some variable using javascript

    Oct 8, 2018 · You can use this construct if you want to populate a variable with a value that needs to be calculated. Note that all calculation happens inside the anonymous function, so you don't pollute the global namespace.

  4. return a variable from a function javascript - Stack Overflow

    Sep 8, 2016 · how do I return a variable from a function and assign it to an object as a property? I wrote this code but it says that the object property is undefined. var mp = {}; function oh() { var greeting = "hello"; var advoir = "goodbye"; return { greeting: greeting, advoir: advoir. }; oh(); mp.greeting = greeting; mp.advoir = advoir;

  5. JavaScript Return Statement - GeeksforGeeks

    Feb 7, 2025 · In this example, the return statement returns the sum of a and b to the caller. If a return statement is used without a value, the function will return undefined. You can return values from a function using the return statement, and these values can …

  6. Function return values - Learn web development | MDN

    Apr 11, 2025 · It's important to understand what their values are, how to use them in your code, and how to make functions return useful values. We'll cover all of these below.

  7. How To Use Return in JavaScript? - GeeksforGeeks

    Feb 17, 2025 · In JavaScript, the return statement is used to specify the value that a function should produce when it is called. It helps in controlling the flow of execution and provides meaningful outputs from functions.

  8. JavaScript return Statement: Returning Value from Function

    Feb 6, 2025 · It serves two primary purposes: to end the execution of a function and to specify a value to be returned to the caller. Understanding how to use the return statement effectively is crucial for writing well-structured and reusable JavaScript code.

  9. JavaScript Return Statements - freeCodeCamp.org

    Jan 21, 2020 · When a function return s a value, the value can be assigned to a variable using the assignment operator (=). In the example below, the function returns the square of the argument.

  10. How to get return value from function in JavaScript?

    Dec 27, 2023 · When you call a function in JavaScript, you can retrieve the return value using a return statement within the function. The return statement specifies the value that the function should return when it is called. Here is how you can get the return value from a …

  11. Some results have been removed
Refresh