Yahoo Malaysia Web Search

Search results

  1. Learn how to use the return statement to stop the execution of a function and return a value. See examples of returning values, strings, and expressions with the return statement.

    • Try It Yourself

      The W3Schools online code editor allows you to edit code and...

    • Js Functions

      Function Return. When JavaScript reaches a return statement,...

  2. Jan 1, 2024 · 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>: js. function draw() { . ctx.clearRect(0, 0, WIDTH, HEIGHT); for (let i = 0; i < 100; i++) { . ctx.beginPath(); .

  3. May 4, 2011 · You can return an array, an object literal, or an object of a type you created that encapsulates the returned values. Then you can pass in the array, object literal, or custom object into a method to disseminate the values. Object example: var returnedObject = {}; returnedObject["value1"] = value1;

  4. Aug 11, 2023 · 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 } .

  5. Learn how to define, invoke, and return values from JavaScript functions. See examples of function syntax, parameters, arguments, and local variables.

  6. Jun 6, 2024 · It can be used to return a specific value, variable, or expression to the caller. If no value is provided, the function returns undefined by default. Syntax: return value; value: The value returned to the function caller. It is an optional parameter. If the value is not specified, the function returns undefined; JavaScript return Statement ...

  7. Jan 21, 2020 · Learn how to use return statements to stop function execution and return values in JavaScript. See examples of primitive values, object types, and undefined returns.