Parameter

In programming, a parameter is a variable that is used to define a function or method. Parameters are placeholders for values that are passed to the function when it is called. They define the input that the function expects to receive.

Parameters are defined in the function’s declaration and provide a way for the function to receive input from the caller. When the function is called, the values passed as arguments are assigned to the corresponding parameters, and the function can then use these values to perform its task.

Examples:

// Function that takes two parameters and returns their sum
function addNumbers(a, b) {
  return a + b;
}

// Calling the function with arguments 5 and 10
let result = addNumbers(5, 10);
console.log(result); // Output: 15

In this example, the addNumbers function defines two parameters, a and b, which represent the two numbers to be added. When the function is called with the arguments 5 and 10, these values are assigned to the parameters a and b, and the function returns their sum, 15.