A JavaScript function is a block of code designed to perform a particular task. Why Functions? You can reuse code: Define the code once, and use it many times. You can use the same code many times with different arguments, to produce different results.