function

A named, reusable block of code that takes inputs, called arguments, and can return a result.

In more detail

Defining a function does not run it; calling it does, usually by writing its name followed by parentheses. Functions let you name a piece of work, reuse it without copying code and test it on its own. In many languages functions are also values that can be stored, passed to other functions and returned.

Examples

func usage(total, used int) (int, error)
V8 counts how often each function runs to decide which ones to optimise.

Related terms

Taught in

References

Certification courses