Drop Right Items
This tool removes a specified number of elements from the end of an array using lodash's _.dropRight method.
Features
- Remove from end: Drop elements from the right side of the array
- Flexible input: Accept any valid JSON array
- Configurable: Specify how many items to drop
- Type preservation: Maintains array structure and data types
Examples
Example 1: Drop last 2 items
Input: [1, 2, 3, 4, 5]
n: 2
Output: [1, 2, 3]
Example 2: Drop last 1 item (default)
Input: ['a', 'b', 'c', 'd']
n: 1
Output: ['a', 'b', 'c']
Example 3: Drop 0 items
Input: [10, 20, 30, 40]
n: 0
Output: [10, 20, 30, 40]
Example 4: Drop more than array length
Input: [1, 2, 3]
n: 10
Output: []
Notes
- If
n is greater than array length, returns empty array []
- If
n is 0, returns a copy of the original array
- Input must be valid JSON array string
- Works with arrays of any type (numbers, strings, objects, nested arrays)