Chapter VI · Functions

Calling Functions

Invoking or calling a function executes the code statements contained within its block.

01 How It Works

Think of pressing the play button on a media player.

Appending parentheses () to a function reference triggers the execution engine.

example.js
function run() {
  console.log("Running...");
}
run(); // Calling the function
  1. 1. Reference the function name or variable.

  2. 2. Append invocation parentheses.

  3. 3. Supply expected arguments.

02 Practical Example

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

practical.js
function alertUser() {
  console.log("Alert triggered!");
}
alertUser();

Key Takeaway

Functions do nothing until explicitly invoked or called.

Related Concepts