Q: How to call partial functions I have this sample code(a .js library needs to be consumed) for formatting the date. Have never used partial functions before so not quite sure how to use it. How does one call them? Here is the utility library code: 
 define(function() {
    'use strict';

     function _formatDate(justNowText, todayFormat, thisWeekFormat, thisYearFormat, veryOldFormat, date) {
       if (!date) { return ""; }

         var formattedMoment = moment(date);
         var now = moment();

       if (now.diff(formattedMoment, "minutes") < 15) {
         return justNowText || "Just now";
       }

       var today = now.startOf('day');
       var dateFormat;

       if (today <= formattedMoment) {
         dateFormat = todayFormat;
       } else if (now.diff(formattedMoment, "days") < 7) {
         dateFormat = thisWeekFormat;
       } else if (formattedMoment.year() >= now.year()) {
         dateFormat = thisYearFormat;
       } else {
         dateFormat = veryOldFormat;
       }

      return formattedMoment.format(dateFormat);

    }

    function asShortTimeStampFilter(gettext) {
     return _.partial(_formatDate,
       gettext("Just now"),
       "h:mm A",
       "ddd",
       "MMM D",
       "M/D/YY"
     );
   }

  function asMediumTimeStampFilter(gettext) {
    return _.partial(_formatDate,
      gettext("Just now"),
      "[" + gettext("Today at") + "] h:mm a",
      "ddd h:mm a",_formatDate
      "MMM D h:mm a",
      "M/D/YYYY h:mm a"
    );
  }

  function asDateTimeFormatFilter(gettext) {
    return function(date, format) {
      if (!date) { return; }

      return moment(date).format(format);
    };
  }

  return {
    asShortTimeStamp: ['gettext', asShortTimeStampFilter],
    asMediumTimeStamp: ['gettext', asMediumTimeStampFilter],
    asDateTimeFormat: ['gettext', asDateTimeFormatFilter]
  };
});


A: Partial application means that you would pass the first argument only to get a function back, which you then could call (multiple times) with the final arguments.
In your case, the library expects a text getter function (e.g. for localisation), and returns the actual formatter function to which you'd pass the date.
function id(x) { return x } // just echo the input
var shortTimeStamp = library.asShortTimeStamp[1](id);

console.log(shortTimeStamp(Date.now()))
console.log(shortTimeStamp(Date.now() - 30000)) // 30s ago
console.log(shortTimeStamp(Date.now() - 720000)) // 2h ago

var mediumGermanTimeStamp = library.asMediumTimeStamp[1](function(t) {
    return {"Just now":"Grad vorhin", "Today at":"Heut um"}[t];
});

console.log(mediumGermanTimeStamp(Date.now()))
console.log(mediumGermanTimeStamp(Date.now() - 30000)) // 30s ago
console.log(mediumGermanTimeStamp(Date.now() - 720000)) // 2h ago

