604 B
Executable File
604 B
Executable File
Array slice and Indexing
Your snippet uses slice and index-based access to create weekly intervals.
slice(0, -1)
const periodStarts = alignedStarts.slice(0, -1);
- Start at index
0. - Stop before the last item (
-1means from the end). - Useful when each
startneeds a followingenditem.
Index access
const end = alignedStarts[index + 1];
- Gets the next boundary after the current
start.
Python comparison
period_starts = aligned_starts[:-1]
end = aligned_starts[index + 1]
This is the same concept as Python slicing and list indexing.