Shift array items by n steps
Given a list of items, return an array that shift right n positions.
import * as import __ from 'radashi'const const arr: number[]arr = [1, 2, 3, 4, 5, 6, 7, 8, 9]import __.shift<number>(arr: readonly number[], n: number): number[]export shiftShifts array items by n steps. If n is greater than 0, items will shift n steps to the right. If n is less than 0, items will shift n steps to the left.@see ― https://radashi.js.org/reference/array/shift@example shift([1, 2, 3], 1) // [3, 1, 2]shift([1, 2, 3], -1) // [2, 3, 1]@version ― 12.1.0shift(const arr: number[]arr, 3) // => [7, 8, 9, 1, 2, 3, 4, 5, 6]
import _
const arr: number[]
shift<number>(arr: readonly number[], n: number): number[]export shift
Shifts array items by n steps. If n is greater than 0, items will shift n steps to the right. If n is less than 0, items will shift n steps to the left.
n
@see ― https://radashi.js.org/reference/array/shift
@example shift([1, 2, 3], 1) // [3, 1, 2]shift([1, 2, 3], -1) // [2, 3, 1]
shift([1, 2, 3], 1) // [3, 1, 2]shift([1, 2, 3], -1) // [2, 3, 1]
@version ― 12.1.0