About 229,000 results
Open links in new tab
  1. Return multiple values in JavaScript? - Stack Overflow

    An expression in return statement — 1, 2, 3 — is nothing but a comma operator applied to numeric literals (1 , 2, and 3) sequentially, which eventually evaluates to the value of its last expression — 3.

  2. What does "return" do in Javascript? - Stack Overflow

    Jun 10, 2017 · Many built-in JavaScript functions have a return value: Math.min() returns the smallest of the arguments passed to it, document.getElementById() returns the HTML element with the id that …

  3. “Syntax error: Illegal return statement” outside a function in JavaScript

    For Node.js users: I discovered that it's possible to use a return statement to exit the current JS script, but only for older-style CommonJS scripts that use the require(x) syntax. Once you switch to the …

  4. javascript - Functions that return a function: what is the difference ...

    return statement: The return statement exits the function and replaces the function call (i.e. where the function was invoked) with the value after it Note: JavaScript returns undefined by default when a …

  5. javascript - Does return stop a loop? - Stack Overflow

    Jul 30, 2012 · Yes, functions always end whenever their control flow meets a return statement. The following example demonstrates how return statements end a function’s execution.

  6. javascript - Is there a benefit to using a return statement that ...

    Sep 15, 2010 · I'm refactoring a large javascript document that I picked up from an open source project. A number of functions use inconsistent return statements. Here's a simple example of what I mean: …

  7. Does every Javascript function have to return a value?

    Jun 27, 2013 · If no return value is specified, JavaScript will return undefined. In many languages the result of the last statement is returned (more useful, IMO). These are called implicit returns.

  8. javascript - Is returning out of a switch statement considered a better ...

    javascript return switch-statement break edited May 25, 2022 at 0:34 Audwin Oyong 2,527 3 21 37

  9. Why use parentheses when returning in JavaScript?

    139 Using parentheses when returning is necessary if you want to write your return statement over several lines. React.js offers a useful example. In the return statement of the render property in a …

  10. javascript - Early exit from function? - Stack Overflow

    May 30, 2018 · @dbme: Functions in JavaScript always return. The return statement is implicit if it hasn't been provided. The default return value is undefined, and that's what my primary solution provides. …