Options
All
  • Public
  • Public/Protected
  • All
Menu

The namespace for the slice function statics.

Callable

  • slice<T>(array: ArrayLike<T>, options?: IOptions): T[]
  • Create a slice of an array subject to an optional step.

    throws

    An exception if the slice step is 0.

    Complexity

    Linear.

    Undefined Behavior

    A start, stop, or step which is non-integral.

    Example

    import { ArrayExt } from '@phosphor/algorithm';
    
    let data = [0, 3, 4, 7, 7, 9];
    ArrayExt.slice(data);                         // [0, 3, 4, 7, 7, 9]
    ArrayExt.slice(data, { start: 2 });           // [4, 7, 7, 9]
    ArrayExt.slice(data, { start: 0, stop: 4 });  // [0, 3, 4, 7]
    ArrayExt.slice(data, { step: 2 });            // [0, 4, 7]
    ArrayExt.slice(data, { step: -1 });           // [9, 7, 7, 4, 3, 0]

    Type parameters

    • T

    Parameters

    • array: ArrayLike<T>

      The array-like object of interest.

    • Default value options: IOptions = {}

      The options for configuring the slice.

    Returns T[]

    A new array with the specified values.

Index

Interfaces