Yahoo India Web Search

Search results

  1. 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.

  2. Aug 11, 2023 · The return statement ends function execution and specifies a value to be returned to the function caller.

  3. Jun 6, 2024 · The return statement in JavaScript is used to end the execution of a function and specifies the value to be returned by that function. The return statement stops the execution of a function and returns a value.

  4. We can return primitive values (such as Boolean, number, string, etc.) and Object types (such as functions, objects, arrays, etc.) by using the return statement.

  5. Feb 2, 2024 · JavaScript allows us to use the return statement to end the function’s execution to specify the value that needs to be returned to the code that is calling it. Below are the methods and examples of how to use a return statement in JavaScript.

  6. Jan 21, 2020 · JavaScript Return Statements. Introduction. When a return statement is called in a function, the execution of this function is stopped. If specified, a given value is returned to the function caller. If the expression is omitted, undefined is returned instead. return expression; Functions can return:

  7. 6 days ago · Some functions don't return a significant value, but others do. It's important to understand what their values are, how to use them in your code, and how to make functions return useful values.

  8. Mar 31, 2024 · Use return to specify the value that the function should produce as a final result. When the interpreter reaches a return statement, the function that contains that statement immediately ends, and the specified value is returned to the context where the function was called: const myFunction = function() { return 2 + 2; } myFunction(); > 4.

  9. This simple code snippet illustrates the syntax of a return statement within a JavaScript function. The return keyword is followed by the value or expression you wish to return from the function. Now, let's dive deeper into the mechanics and best practices of using return in JavaScript.

  10. Mar 31, 2021 · The return keyword in JavaScript is a keyword to build a statement that ends JavaScript code execution. For example, suppose you have the following code that runs two console logs: console.log("Hello"); return; console.log("How are you?");