"Invert" a JavaScript object hash whose values are arrays to produce a new object hash with keys as the elements of those original value vectors
lodash and underscore both have a reduce (aka "fold") function that works on objects, meaning you could also do this:

function arrayAwareInvert(obj) {
  return _.reduce(obj, function (result, values, key) {
    _.forEach(values, function (value) { result[value] = key; });
    return result;
  }, {});
}


It's pretty much the functional-style equivalent of Bergi's answer.

Point is, reduce is probably what you want for this.



Edit: As Bergi points out in the comments the inner iteration could also be a reduce operation

function arrayAwareInvert(obj) {
  return _.reduce(obj, function (result, values, key) {
    return _.reduce(values, function (result, value) {
      result[value] = key;
      return result;
    }, result);
  }, {});
}