Many of us still think that arguments and parameters are the same. But that is not the case. They're different. So, today we're gonna look at the differences between arguments and parameters. Let's get started!
// Here a and b are Parameters
function add(a, b) {
return a + b
}
// Here 2 and 4 are Arguments
console.log(add(2, 4))
Take a look at this code snippet. we have a function named add, that essentially sums up two numbers and then returns. In function add, we have a and b enclosed by parentheses. They are parameters. In other words, functions have parameters. And after that, we're calling that function using the function name add, and we're passing two numbers (2 and 4) to it. This is known as arguments.
So, in brief
Functions have something enclosed in parentheses. That something is known as parameters.
And, when the function is called using its name, then you will pass something to it. That something is known as arguments.
That's all about Arguments and Parameters. Have a great day!