A function is a reusable block of code that takes arguments and returns a value, the main tool for keeping code DRY (Don't Repeat Yourself). Functions are also first-class objects: you can store, pass, return and extend them, which underlies callbacks, closures, constructors and functional patterns.