function slice(arr, start, opt_end) {
  asserts.assert(arr.length != null);

  // passing 1 arg to slice is not the same as passing 2 where the second is
  // null or undefined (in that case the second argument is treated as 0).
  // we could use slice on the arguments object and then use apply instead of
  // testing the length
  if (arguments.length <= 2) {
    return Array.prototype.slice.call(arr, start);
  } else {
    return Array.prototype.slice.call(arr, start, opt_end);
  }
}
Returns a new array from a segment of an array. This is a generic version of
Array slice. This means that it might work on other objects similar to
arrays, such as the arguments object.

@param {IArrayLike<T>|string} arr The array from
which to copy a segment.
@param {number} start The index of the first element to copy.
@param {number=} opt_end The index after the last element to copy.
@return {!Array<T>} A new array containing the specified segment of the
    original array.
@template T