array/drop.jsjavascript
/**
* 从数组左侧移除指定数量的元素。
* @function drop
* @memberof module:array
* @param {Array} array 原数组
* @param {number} [count=1] 移除数量,小于等于零时不移除
* @returns {Array} 新数组
* @throws {TypeError} 参数类型不正确时抛出
*/
function drop(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 array.slice(Math.max(0, count))
}
export default drop