array/dropRight.jsjavascript
/**
 * 从数组右侧移除指定数量的元素。
 * @function dropRight
 * @memberof module:array
 * @param {Array} array 原数组
 * @param {number} [count=1] 移除数量,小于等于零时不移除
 * @returns {Array} 新数组
 * @throws {TypeError} 参数类型不正确时抛出
 */
function dropRight(array, count = 1) {
  if (!Array.isArray(array)) throw new TypeError('array must be an array')
  if (!Number.isInteger(count)) throw new TypeError('count must be an integer')
  return count <= 0 ? array.slice() : array.slice(0, -count)
}

export default dropRight