JavaScript
Function
A reusable block of code that takes input, does something, and can return a result.
Reviewed by the RadarTrek editorial team · June 2026
A function packages up a sequence of instructions so you can run it repeatedly without rewriting the logic. Functions can accept parameters (inputs) and return a value (output). They're the basic unit of reuse in JavaScript and almost every other programming language.
Why it matters
- —Functions are how you avoid repeating yourself — write the logic once, call it everywhere.
- —Most bugs are easier to find when logic is broken into small, well-named functions.
- —React components are themselves functions — understanding functions is a prerequisite for React.
Where to learn this
🎓
Functions in JavaScript
JavaScript Fundamentals course
This is the exact lesson that covers this term in depth — with examples, diagrams, and a hands-on exercise.