code: function substring(str, start, end) {
    start = start || 0;
    end   = (end === undefined) ? Infinity : (end || 0);
  
    if (start < 0) {
      start = 0;
    }
    if (end < 0) {
      end = 0;
    }
  
    const length = Math.abs(end - start);
    start = (start < end) ? start : end;
    return substr(str, start, length);
  }
docs: Fully Unicode-enabled replacement for String#substring()
  
  @param {string} str    Valid Unicode string
  @param {number} start  Location in Unicode sequence to begin extracting
  @param {?number} end   Location in Unicode sequence to end extracting
  (default: end of the string)
  @return {string}       Extracted sub-string