Arguments Versus Parameters in Programming...Understanding the differences

Introduction

In this article, we'll discuss the differences between these two(2) keywords: Arguments and Parameters in Programming. These are terms that are often misunderstood and sometimes interchanged when talking about functions.

Definitions

What are the Parameters?

Parameters in simple terms are placeholders for what is needed in the future in a function.

What are Arguments?

Arguments are values used as input to a function.

Code Snippets

function addNumbers(x, y) {
   return x + y;
};
addNumbers(2, 3);

Code Explanation

  • In the first code snippet, we created a function to add numbers.

  • We are expecting two values to be received in the function, namely: x and y

  • Those values are what we call Parameters.

  • The x and y acts as a placeholder for any value we plan on inserting into the function in the future when it's being called.

  • In the second code snippet, we called the function already created in code snippet 1, and passed some values to it.

  • The values "2" and "3" replaced the placeholders "x" and "y".

  • Those values here are referred to as Arguments.

Conclusion

Parameters are just spaces we reserve for use in the future while Arguments are items or values we insert into those spaces when the function or code is needed in the future.