Reuse Code With Functions in JavaScript
JavaScript·1 min read·Jan 1, 2026
In JavaScript, a function is a reusable code structure that allows you to encapsulate a set of related statements in order to perform a specific task.
Functions allow you to easily reuse and execute these statements multiple times from various parts of a script, without having to manually repeat them.
💡 Note that executing, calling, running, and invoking a function essentially mean the same thing and are often used interchangeably.
Declare and execute functions
In JavaScript, functions are declared using the function keyword:
function functionName() { statements}Where:
-
functionNameis the name of the function. -
()are delimiters used to list function parameters.