
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 .
javascript - Functions that return a function: what is the …
Assigning a variable to a function (without the parenthesis) copies the reference to the function. Putting the parenthesis at the end of a function name, calls the function, returning the functions return value. alert('A'); alert('B'); return a; alert('C'); return a(); In your example, you are also defining functions within a function. Such as:
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 } .
How to return values in javascript - Stack Overflow
May 4, 2011 · value3=somevalue3 //to return. function call in Code: .... in this scenario how to pass value2 and value3 to the called method or how to return values in Java script. You can return an array, an object literal, or an object of a type …
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 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.
What does "return" do in Javascript? - Stack Overflow
Jun 10, 2017 · I'm currently trying to learn Javascript and I don't really undesrtand the purpose of "return". I made a "rock, paper, scissors" game at the end of my lesson, using the return function. The game looks like this: var userChoice = prompt("Do you choose rock, paper or scissors?"); computerChoice = "rock"; computerChoice = "paper";
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. When the function resolves or ends, its value is the return ed value. The value is then assigned to the variable squared2.
JavaScript return - function return values - ZetCode
Apr 16, 2025 · In this article we show how to use the return keyword to return values from functions in JavaScript. The return keyword is used to specify the value that a function should return when it is called. When JavaScript encounters a return statement, it immediately exits the function and returns the specified value to the caller.
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 …
- Some results have been removed