
JavaScript return Statement - W3Schools
The return statement stops the execution of a function and returns a value. Read our JavaScript Tutorial to learn all you need to know about functions. Start with the introduction chapter about JavaScript Functions and JavaScript Scope. For more detailed information, see our Function Section on Function Definitions, Parameters, Invocation and ...
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.
How To Use Return in JavaScript? - GeeksforGeeks
Feb 17, 2025 · The return statement in JavaScript is used to end a function execution and send a value back to where the function was called. It allows the function to provide useful results, like numbers, strings, or objects, that can be used in other parts of the code.
return - JavaScript | MDN - MDN Web Docs
Mar 13, 2025 · In a plain function, the call to that function evaluates to the return value. In an async function, the produced promise is resolved with the returned value. In a generator function, the produced generator object's next() method returns { done: true, value: returnedValue }.
JavaScript Return Statement - GeeksforGeeks
Feb 7, 2025 · The return statement in JavaScript is used to end the execution of a function and return a value to the caller. It is used to control function behaviour and optimise code execution. Syntax return [expression]Expression Evaluation: The expression inside the brackets is evaluated and returned to the c
How a Function Returns an Object in JavaScript - GeeksforGeeks
Oct 6, 2023 · When a function returns an object in JavaScript, it follows a specific sequence of steps. Let's break down the working of a function returning an object. The process starts with defining a JavaScript function. This function will be responsible for …
JavaScript Return Statements - freeCodeCamp.org
Jan 21, 2020 · function myfunction (arg1, arg2) { var r; r = arg1 * arg2; return (r); } Run Code. When a function returns 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. When the function resolves or ends, its value is the returned
How to Return a Value in JavaScript - ThoughtCo
Jun 24, 2019 · JavaScript passes a value from a function back to the code that called it by using the return statement. The value to be returned is specified in the return. That value can be a constant value, a variable, or a calculation where the result of the calculation is returned. For example: return 3;
JavaScript Return Statements – TheLinuxCode
Dec 11, 2024 · Return statements are critical in JavaScript for functions to send data back to the caller. When executed, they stop function execution and return a value to the calling code. This enables reusable logic that can calculate, manipulate, or process data in …
How to use return statement in JavaScript - coderspacket.com
Jan 4, 2025 · The return statement is the premise for writing effective and reusable functions in JavaScript. Knowing its syntax and an example will enable developers to write cleaner more efficient code.
- Some results have been removed