Function createCommon

  • Creates an array of common elements between two arrays.

    Type Parameters

    • T

      The type of elements in the arrays.

    Parameters

    • A: T[]

      The first array.

    • B: T[]

      The second array.

    Returns T[]

    An array containing the common elements between the two arrays.

    import { createCommon } from "@std/internal/diff";
    import { assertEquals } from "@std/assert";

    const a = [1, 2, 3];
    const b = [1, 2, 4];

    assertEquals(createCommon(a, b), [1, 2]);