* Creates a slice of `array` with `n` elements dropped from the end. * * @static * @memberOf _ * @since 3.0.0 * @category Array * @param {Array} array The array to query. * @param {number} [n=1] The number of elements to drop. * @param- {Object} [guard] Enable
(array, n, guard)
| 7174 | * // => [1, 2, 3] |
| 7175 | */ |
| 7176 | function dropRight(array, n, guard) { |
| 7177 | var length = array == null ? 0 : array.length; |
| 7178 | if (!length) { |
| 7179 | return []; |
| 7180 | } |
| 7181 | n = (guard || n === undefined) ? 1 : toInteger(n); |
| 7182 | n = length - n; |
| 7183 | return baseSlice(array, 0, n < 0 ? 0 : n); |
| 7184 | } |
| 7185 | |
| 7186 | /** |
| 7187 | * Creates a slice of `array` excluding elements dropped from the end. |