JSVerse
Fundamentals / Functions

Functions

Reusable blocks of behavior — declared, expressed, or arrow-shaped.

A function packages a block of code under a name so it can run whenever it's called, with different inputs each time. Function declarations are hoisted (usable before their line); function expressions and arrow functions are not. Parameters can have defaults, and `...rest` gathers any extra arguments into an array.

Codeeditable — Run executes your edits
Loading...
Console
Output will appear here
Visualization
State
Step through — the console panel shows what's happening
Why?

Default parameters only kick in when an argument is undefined or omitted entirely — passing null still overrides the default.