GoConqr hat ein neues Design! Sag uns, wie es dir gefällt.

Modul 4 von 16 · Medien

Arguments

Kostas Diakogiannis

Arguments

JS Functions Arguments

Arguments are local variables that are defined inside parentheses after function declaration and are accessed only inside the body of the function.

No outer scope has access to arguments unless the value of these arguments is returned from the function.

They are extremely powerful and useful feature as they allow us to parameterize the result of the function. The basic functionality remains the same but the result can alter based on the values we have passed to the arguments any time we call (invoke) the function.

Thus, functions can be really a re-usable piece of code, that we define only once, but we can call and execute the same functionality, with different results. The example above defines a function that accepts two arguments. The functionality is the same, it adds these arguments and returns the sum of them. 

Calling the function by passing 10 and 15 as arguments returns 25,

second time same function, different arguments returns 45.

Anleitung

Um im Kurs weiterzukommen, sende einen Versuch dieses Quiz ab. Du kannst ihn nach der letzten Frage absenden.

Zum gewählten Modul

Feedback

Worum geht es?

Wie gefällt dir das neue Design?

Dein Eindruck