A function is a block of code which can be called by an event or even by another function. Functions can perform any number of program tasks, but only execute when called. Functions can be called by events or even other functions.
One key advantage of functions is that they are reusable. This is to say that they can be called as many times as necessary during script execution.