code: function hasDuplicates(arr, fn) {
    var obj = {};
    var i, l, elem;
    for (i = 0, l = arr.length; i < l; i++) {
      elem = arr[i];
      if (fn) {
        elem = fn(elem);
      }
      if (obj[elem]) {
        return true;
      }
      obj[elem] = true;
    }
    return false;
  }
docs: Check whether an array has duplicates.
  
  @param arr {Array} The array.
  @param fn {Function} Optional function to apply to each element.