Imagine we define a function that returns the time:
var sayTime = function() { return Date.now() };
Calling this function will always give us the present time (expressed in the number of milliseconds elapsed since January 1, 1970).
sayTime(); // 1527745490828 sayTime(); // 1527745493242 sayTime(); // 1527745494395
With Underscore's before function we can create a new version of this function that is can only be called a certain number of times.
var sayTimeLimited = _.before(3, sayTime); // First call sayTimeLimited(); // 1527745553103 // Second call sayTimeLimited(); // 1527745557316 // Third call (and beyond) will return the memoized result of the previous call. sayTimeLimited() // 1527745557316