Drop Right Items
Drop last N items from array using lodash _.dropRight
## 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**
```json
Input: [1, 2, 3, 4, 5]
n: 2
Output: [1, 2, 3]
```
**Example 2: Drop last 1 item (default)**
```json
Input: ['a', 'b', 'c', 'd']
n: 1
Output: ['a', 'b', 'c']
```
**Example 3: Drop 0 items**
```json
Input: [10, 20, 30, 40]
n: 0
Output: [10, 20, 30, 40]
```
**Example 4: Drop more than array length**
```json
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)
API Documentation
Request Endpoint
POST /en/api/tools/drop-right-items
Request Parameters
| Parameter Name | Type | Required | Description |
|---|---|---|---|
| array | textarea | Yes | Enter a valid JSON array |
| n | number | No | How many items to drop from the end of the array |
Response Format
{
"result": "Processed text content",
"error": "Error message (optional)",
"message": "Notification message (optional)",
"metadata": {
"key": "value"
}
}
Text:
Text
AI MCP Documentation
Add this tool to your MCP server configuration:
{
"mcpServers": {
"elysiatools-drop-right-items": {
"name": "drop-right-items",
"description": "Drop last N items from array using lodash _.dropRight",
"baseUrl": "https://elysiatools.com/mcp/sse?toolId=drop-right-items",
"command": "",
"args": [],
"env": {},
"isActive": true,
"type": "sse"
}
}
}
You can chain multiple tools, e.g.: `https://elysiatools.com/mcp/sse?toolId=png-to-webp,jpg-to-webp,gif-to-webp`, max 20 tools.
If you encounter any issues, please contact us at [email protected]