
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.
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 multiple values in JavaScript? - Stack Overflow
No, but you could return an array containing your values: function getValues() { return [getFirstValue(), getSecondValue()] } Then you can access them like so: const [first, second] = getValues() This is called destructuring assignment and is supported by every major JS environment. It's equivalent to the following:
Using function's return value in if statement - Stack Overflow
Jul 15, 2011 · Can you use a function's returned value in a if statement? I.e. function queryThis(request) { return false; } if(queryThis('foo') != false) { doThat(); } Very simple and obvious I'm sure, but I'm running into a number of problems with …
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 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
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 value.
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 }.
Understanding Return Values in JavaScript Functions - Codequick
Learn how to work with return values in JavaScript functions and leverage their power in your code.
How to Return Values of a Function in JavaScript | Delft Stack
Feb 2, 2024 · The function can return anything like an array, literal object, string, integer, a boolean value, or an object of a custom type you create that encapsulates the return values. You can pass anything to the function like an array, literal object, or …