An inline function is defined where it is used instead of being assigned a separate name. It is usually anonymous and works best for a short operation needed once. section 10.12 section 12.5
Distinguish three ways to define and pass a function:
- Define it globally and refer to it by name from elsewhere. section 10.12
- Define and name it locally when it needs local values but should remain within that scope. section 10.12
- Define it inline as an anonymous function when the operation is short and used once. section 12.5
Passing an inline callback
map(customers, function(customer) { return emailForCustomer(customer, goods, bests); }); map calls the callback once for each array element, so naming its argument customer makes the operation clear. section 12.4
withLogging(function() {
saveUserData(user);
});
Compare an inline callback with a separately named function passed to withLogging. section 10.12



