What Is An Argument?

PHP Developer Freelance | E-learning Platform external link
🔗 See other jobs


When you take a look at mathematical formulas most of them usually have alphabets say x or y in them, and the intention is that anyone using these formulas will replace the x and ys with actual values. In the programming world functions can be viewed as these formulas and arguments will be the values you pass in to replace x and y

Use Cases and Examples

Here is an example of a function in Javascript that adds two parameters together:

01: // declaring the function
02: function adder(a, b) {
03:     return a+b;
04: }
06: // using the function
07: adder(1,2);

What you have above is a function called adder that takes two parameters and returns the sum of a and b. The last bit of the code shows how you will use this function. You will refer to the values you pass in to replace the parameters as arguments.


Your output will always correspond to what you passed in as arguments to a function or method.

Here is another article you might like 😊 "What Is An Integrated Development Environment IDE?"