1

Different sources explain it in a different ways. In the below example, which are arguments and which are parameters?

 const add = function(number1, number2){
       return number1 + number2
           }

    add(3,10)

thanks!

0

2 Answers 2

1

Edit: as another user pointed out, this is a duplicate. What is the difference between arguments and parameters in javascript?


Arguments are what's passed to a function at runtime. Parameters are what are defined in the function definition and alias the arguments.

Parameters are variables listed as a part of the function definition.

Arguments are values passed to the function when it is invoked.

Source: https://codeburst.io/parameters-arguments-in-javascript-eb1d8bd0ef04

function moo(number1, number2) {} // parameters are defined

moo(10, 50, 100); // arguments are passed.
// notice that more than the specified number of parameters
// can be supplied and accessed via 'arguments'

Also see arguments:

arguments is an Array-like object accessible inside functions that contains the values of the arguments passed to that function.

Sign up to request clarification or add additional context in comments.

Comments

1

Parameters are variables listed as a part of the function definition. Arguments are values passed to the function when it is invoked.

const add = function(number1, number2){ //Arguments
   return number1 + number2 //Parameters
       }

add(3,10)

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.