A function in JavaScript is a reusable block of code that performs a specific task. Functions are defined with the function keyword, followed by a name and a set of parentheses which can include parameters. The code to be executed by the function is placed inside curly brackets {}. Functions can be invoked (called) elsewhere in the program, allowing for modularity and reusability. They can also return a value to the part of the program where they were called from.
For example:
```
function addNumbers(a, b) {
return a + b;
}
var result = addNumbers(5, 10); // result now holds the value 15
```