Skip to content
>devspeak
← glossary
level 0Foundations

Function

also: functions

A named chunk of code that does one job. Other parts of the app can use it whenever that job needs doing, instead of repeating the same steps.

a bit more technical

A reusable, named block of code that takes inputs (arguments), performs a task, and often returns a result. Functions let programmers avoid repetition and split programs into small, testable pieces. Functions attached to objects are often called methods.

picture it

A function is like the "latte" button on a coffee machine. You press it, it runs the same steps every time, and a latte comes out. You never redo each step by hand.

why it matters

Agents often name the function they changed or created. Knowing a function is one small job helps you ask focused questions, like "which function calculates the total?"

what your agent might say
agent
The bug was in the formatDate function. It assumed every month has 31 days. I fixed it there, so every page that uses it is fixed too.
how you might use it
you → your agent
Find the function that decides whether a class is full, and explain what it checks before you change it.
common mistake

Thinking a function is a feature of the app. A feature like "checkout" is usually built from many small functions working together.

builds on