← JavaScript Essentials
Control flow and functions · 15 MIN

Functions and parameters

Functions and parameters

Functions can receive parameters and return values. Function declarations are hoisted; function expressions and arrow functions are assigned to variables. Keep functions focused on one task and avoid unnecessary global state.

Try it yourself

Change the example, run it, and explain the result in your own words. Then create one variation of your own.

Key idea

Use the example as a starting point, not something to memorize. Practise, inspect the result and make small improvements.

Code example

function add(a, b) { return a + b; }
const double = value => value * 2;
console.log(add(2, 3), double(4));