Chapter VI · Functions

Parameters

Parameters are placeholder variables defined in a function signature to accept incoming input data.

01 How It Works

Think of blank input fields on a form waiting to be filled out.

Parameters act as local variables inside the function body initialized by passed argument values.

example.js
function greet(name) {
  console.log(`Hello ${name}`);
}
  1. 1. Declare a function with parentheses.

  2. 2. List parameter identifiers inside.

  3. 3. Reference parameters in code logic.

02 Practical Example

Here is how you might see this concept applied in real-world code:

practical.js
function calculateTax(amount, rate) {
  return amount * rate;
}

Key Takeaway

Parameters allow functions to accept dynamic inputs.

Related Concepts