Function slice

  • It will create a slice of the value (array/string) from start, up to, but not including, end.

    Type Parameters

    • Value extends string | unknown[]

    Parameters

    • value: Value
    • start: number = 0
    • end: number = value.length

    Returns Value

    Since

    1.0.0

    Example

    slice([0, 1, 2, 3, 4, 5], 2);
    // => [2, 3, 4, 5]

    Example

    slice([0, 1, 2, 3, 4, 5], 2, 5);
    // => [2, 3, 4]

    Example

    slice("012345");
    // => "012345"

    Example

    slice("012345", 2, 4);
    // => "23"