javascript

Arguments And Parameters


Parameters 


Parameters are variables listed as part of the function declaration. They are placeholders for values that will be provided when the function is called. Parameters are specified within the parentheses () following the function name.

 

Syntax:

function functionName(parameter1, parameter2, parameter3) {
    // code to be executed
}

 

Example:

function add(a, b) {
    return a + b;
}
    
var result = add(3, 4);
console.log(result); // 7

 

Arguments


Arguments are the actual values that are passed to a function when it is called. They correspond to the parameters of the function. When a function is called, the arguments are provided within the parentheses ().

 

Syntax:

function_name(argument1, argument2, ...);

 

Example:

function add(a, b) {
    return a + b;
}
    
var result = add(3, 4);
console.log(result); // 7