What is the difference between arguments and parameters in javascript?

Programmers often use the terminology parameters and arguments interchangeably but they are not the same.

So, what is the difference between parameters and arguments?

Parameters are variables that get passed into a function when we define function. Parameters get assigned with the values of arguments.

Arguments are values that are passed into a function when we invoke function.

Let me illustrate with an example.

function areaRect( length, breadth ){
  console.log( length * breadth );

Here we have a function named areaRect. It will calculate the area of rectangle by taking two variables length and breadth. These two variables are called parameters. They are part of function declaration.

Now let’s call that function areaRect.

areaRect( 4 , 3 )
// 12

Here we invoked or called function areaRect by passing numeric values 4 and 3. These values are called arguments. Arguments are part of function invocation. So we can also say we invoked areaRect function with arguments 4 and 3.

Here parameter length will be assigned to value 4 and parameter breadth will be assigned to value 3.

You don’t always need to pass values as argument. You can also pass variables or expression as arguments.

(variables as arguments)

let l = 4;

let b = 3;

areaRect( l ,b )
// 12

Here values of variables are assigned to parameters.

(expressions as arguments)

areaRect( 18/2 , 9/3);
// 12

Here numeric expression is evaluated first and then that value is assigned to parameters.