Région de recherche :

Date :

https://stackoverflow.com › questions › 8928306

javascript - When should I use return? - Stack Overflow

return is used to send a value back to where's it's called from. You use it if you want to return a value. If you don't have a return statement, it's the same as return undefined. console.log returns undefined, so return console.log(text) returns undefined. So, only return if you want to get a value from the function.

https://developer.mozilla.org › fr › docs › Web › JavaScript › Reference › Statements › return

return - JavaScript | MDN - MDN Web Docs

Lorsqu'une instruction return est utilisée dans une fonction, l'exécution de la fonction se termine. Si une valeur est fournie, elle sera renvoyée à l'appelant de la fonction. Si l'expression définissant la valeur de retour de la fonction est absente, la valeur undefined sera renvoyée.

https://developer.mozilla.org › en-US › docs › Web › JavaScript › Reference › Statements › return

return - JavaScript | MDN - MDN Web Docs

When a return statement is used in a function body, the execution of the function is stopped. The return statement has different effects when placed in different functions: In a plain function, the call to that function evaluates to the return value.

https://mindsers.blog › fr › post › fonction-instruction-return-javascript

[JS] Comprendre l'instruction de retour des fonctions - Mindsers Blog

Pour terminer une fonction, JavaScript utilise l'instruction return. L'instruction return est très simple. C'est d'ailleurs une des premières que l'on voit dans les cours de programmation.

[JS] Comprendre l'instruction de retour des fonctions - Mindsers Blog

https://www.w3schools.com › jsref › jsref_return.asp

JavaScript return Statement - W3Schools

Syntax. return value; Parameters. More Examples. Calculate the product of two numbers and return the result: // Call a function and save the return value in x: var x = myFunction (4, 3); function myFunction (a, b) { // Return the product of a and b. return a * b; } Try it Yourself » Related Pages. JavaScript Tutorial: JavaScript Functions.

https://www.full-skills.com › fr › javascript › javascript-return

Maîtriser l'art des déclarations de retour JavaScript

Commençons par explorer la structure de base d'une instruction return JavaScript : Le code. fonction ajouter (a, b) {. retourne a + b; Dans cet exemple simple, la fonction add prend deux nombres, a et b, et renvoie leur somme en utilisant le retourner déclaration.

https://developer.mozilla.org › fr › docs › Learn › JavaScript › Building_blocks › Return_values

Valeurs de retour des fonctions - Apprendre le développement web - MDN

Pour retourner une valeur d'une fonction que vous avez créée, vous devez utiliser le mot-clef return. Nous avons vu son utilisation dans l'exemple random-canvas-circles.html. La fonction draw() dessine 100 cercles aléatoires dans un élément HTML <canvas> : js. function draw() { .

https://web.dev › learn › javascript › functions › return

The return keyword - web.dev

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.

http://devdoc.net › web › developer.mozilla.org › en-US › docs › Web › JavaScript › Reference › Statements › return.html

return - JavaScript | MDN

Description. When a return statement is used in a function body, the execution of the function is stopped. If specified, a given value is returned to the function caller. If the expression is omitted, undefined is returned instead. The following return statements all break the function execution: return; return true; return false; return x;

https://runebook.dev › fr › docs › javascript › statements › return

JavaScript - return [fr] - Runebook.dev

Lorsqu'une instruction return est utilisée dans le corps d'une fonction, l'exécution de la fonction est arrêtée. L'instruction return a des effets différents lorsqu'elle est placée dans différentes fonctions : Dans une fonction simple, l'appel à cette fonction est évalué à la valeur de retour.