
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.
return - JavaScript | MDN - MDN Web Docs
Mar 13, 2025 · In a generator function, the produced generator object's next() method returns { done: true, value: returnedValue }. In an async generator function, the produced async generator object's next() method returns a promise fulfilled with { done: true, value: returnedValue }.
javascript - Functions that return a function: what is the …
Calling the function with in a return statement executes the function, and returns whatever value was returned by the function. It is similar to calling var x = b(); , but instead of assigning the return value of b() you are returning it from the calling function a() .
JavaScript Functions - W3Schools
Function Return. When JavaScript reaches a return statement, the function will stop executing. If the function was invoked from a statement, JavaScript will "return" to execute the code after the invoking statement. Functions often compute a return …
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
How to return values in javascript - Stack Overflow
May 4, 2011 · 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 keyword. Share
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.
JavaScript Return Statements - freeCodeCamp.org
Jan 21, 2020 · The following function returns the product of its arguments, arg1 and arg2. function myfunction ( arg1, arg2 ) { var r; r = arg1 * arg2; return (r); } Run Code
Function return values - Learn web development | MDN - MDN Web Docs
Apr 11, 2025 · To return a value from a custom function, you need to use the return keyword. We saw this in action recently in our random-canvas-circles.html example. Our draw() function draws 100 random circles somewhere on an HTML <canvas>: ctx.clearRect(0, 0, WIDTH, HEIGHT); for (let i = 0; i < 100; i++) { . ctx.beginPath(); .
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 …