function map(obj, f, opt_obj) {
  const res = {};
  for (const key in obj) {
    res[key] = f.call(/** @type {?} */ (opt_obj), obj[key], key, obj);
  }
  return res;
}
For every element in an object/map/hash calls a function and inserts the
result into a new object.
@param {?Object<K,V>} obj The object over which to iterate.
@param {function(this:T,V,?,?Object<K,V>):R} f The function to call for every
    element. This function takes 3 arguments (the value, the key and the
    object) and should return something. The result will be inserted into a
    new object.
@param {T=} opt_obj This is used as the 'this' object within f.
@return {!Object<K,R>} a new object with the results from f.
@template T,K,V,R