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.
The first array.
The second array.
const array1 = [1, 2, 3, 4];const array2 = [3, 4, 5, 6];const result = difference(array1, array2);// result will be [1, 2] Copy
const array1 = [1, 2, 3, 4];const array2 = [3, 4, 5, 6];const result = difference(array1, array2);// result will be [1, 2]
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.