Key Facts
- Category
- Data Processing
- Input Types
- textarea, number
- Output Type
- text
- Sample Coverage
- 4
- API Ready
- Yes
Overview
The Drop Right Items tool uses lodash's _.dropRight method to remove a specified number of elements from the end of an array. It provides a quick and reliable way to truncate arrays while preserving data types and structure.
When to Use
- •When you need to trim trailing elements from an array for data cleaning.
- •To remove the last few items in a list during data preprocessing.
- •For array manipulation in scripts or workflows where end elements are unnecessary.
How It Works
- •Input a valid JSON array into the designated field.
- •Optionally specify the number of items to drop from the end using the n parameter.
- •The tool processes the input and returns a new array with the last n items removed.
- •Handles edge cases: if n is 0, returns a copy; if n exceeds length, returns an empty array.
Use Cases
Examples
1. Trim Sales Data Array
Business Analyst- Background
- An array contains daily sales figures, but the last two days are incomplete and should be excluded from the report.
- Problem
- The array has extra elements that skew the analysis.
- How to Use
- Enter the array [1500, 2000, 1800, 2200, 1900] and set n to 2.
- Example Config
-
Array: [1500, 2000, 1800, 2200, 1900], n: 2 - Outcome
- The tool returns [1500, 2000, 1800], removing the last two sales figures.
2. Remove Last Error Message
Developer- Background
- During debugging, an array of error logs has a final entry that is a system-generated placeholder.
- Problem
- The array includes an irrelevant last element.
- How to Use
- Input the array ['Syntax error', 'Null pointer', 'Timeout', 'Debug info'] and use n=1.
- Example Config
-
Array: ['Syntax error', 'Null pointer', 'Timeout', 'Debug info'], n: 1 - Outcome
- The output is ['Syntax error', 'Null pointer', 'Timeout'], with the last item dropped.
Try with Samples
json, videoRelated Hubs
FAQ
What is the default number of items dropped?
The default is 1, meaning it drops the last item by default.
Can I drop zero items?
Yes, setting n to 0 returns a copy of the original array without any changes.
What happens if I try to drop more items than the array has?
If n is greater than the array length, the tool returns an empty array.
Does this tool modify the original array?
No, it returns a new array; the input array remains unchanged.
What types of arrays are supported?
It supports any valid JSON array, including numbers, strings, objects, and nested arrays.