Functions: Function parameters

Join the AI Workshop to learn more about AI and how it can be applied to web development. Next cohort February 1st, 2026

The AI-first Web Development BOOTCAMP cohort starts February 24th, 2026. 10 weeks of intensive training and hands-on projects.


A function can have no parameter, like we’ve seen previously:

function test() {
  //do something
}

Or it can have one or more parameters, which are declared inside the parentheses:

function test(color) {
  //do something
}

function test(color, age) {
  //do something
}

When we can pass a parameter, we invoke the function passing arguments:

function test(color, age) {
  //do something
}

test("green", 24)
test("black")

The difference between arguments and parameters is this: you define the parameters and that’s what you see inside the function. Arguments are passed by the program when you call the function.

They are basically the value assigned to the parameter.

Functions can have default values for the parameters that are not passed by the caller:

function test(color = 'red', age = 20) {
  console.log(color, age)
}

test("green", 24)
test("black")

Lessons in this unit:

0: Introduction
1: ▶︎ Function parameters
2: Returning values from a function
3: Arrow functions
4: Nesting functions
5: Immediately-invoked functions
6: Recursive functions