Function difference

  • Creates an array of array values not included in the other given arrays using SameValueZero for equality comparisons. The order and references of result values are determined by the first array.

    Note: Unlike pullAll, this method returns a new array.

    Parameters

    • array: any

      The array to inspect.

    • Rest ...values: any[]

      The values to exclude.

      Rest

    Returns any

    Returns the new array of filtered values.

    Since

    5.9.0

    See

    union, unionBy, unionWith, without, xor, xorBy, xorWith,

    Example

    difference([2, 1], [2, 3])
    // => [1]