Code
Loading editor...
Tap Analyze to see visualization
Click Analyze to visualize
See step-by-step execution, variables, and output
Variables
Run code to see variables
Output
Console output will appear here
Click Analyze to visualize
See step-by-step execution, variables, and output
Run code to see variables
Console output will appear here
Normalize start and end indices, handling undefined defaults and negative values by adding them to the array length. Iterate from the computed start to end, copying each element into a new result array without modifying the original.
Slice creates a shallow copy of a portion of the array. Negative indices count from the end, enabling patterns like arr.slice(-3) to get the last three elements without knowing the array length.
Updated Feb 2026