A JavaScript function is a block of code that performs a specific task and can be reused by calling the function multiple times with different arguments to produce different results. Functions are defined using the function keyword followed by a name and parentheses, and the code inside the curly brackets is executed when the function is called.