@tremendous/help
    Preparing search index...

    Function difference

    • Computes the difference between two arrays.

      This function returns an array containing the elements that are present in the first array but not in the second array.

      Type Parameters

      • T

      Parameters

      • arr1: T[]

        The first array.

      • arr2: T[]

        The second array.

      Returns T[]

      • The difference between the first and second arrays.
      const array1 = [1, 2, 3, 4];
      const array2 = [3, 4, 5, 6];
      const result = difference(array1, array2);
      // result will be [1, 2]