A reusable block of code that performs a specific task and can accept inputs (parameters) and optionally return a result. Functions help organize code into manageable, testable pieces that can be called multiple times.
From Latin 'functio' meaning 'performance' or 'execution.' Mathematical functions, which map inputs to outputs, provided the conceptual foundation when programming languages adopted the term in the 1950s. The programming meaning expanded to include any callable code block, not just mathematical operations.
Try Another Word