|
Last change
on this file was a762898, checked in by istevanoska <ilinastevanoska@…>, 5 months ago |
|
Added visualizations
|
-
Property mode
set to
100644
|
|
File size:
1.1 KB
|
| Line | |
|---|
| 1 | /**
|
|---|
| 2 | * Computes the difference between two arrays.
|
|---|
| 3 | *
|
|---|
| 4 | * This function takes two arrays and returns a new array containing the elements
|
|---|
| 5 | * that are present in the first array but not in the second array. It effectively
|
|---|
| 6 | * filters out any elements from the first array that also appear in the second array.
|
|---|
| 7 | *
|
|---|
| 8 | * @template T
|
|---|
| 9 | * @param {T[]} firstArr - The array from which to derive the difference. This is the primary array
|
|---|
| 10 | * from which elements will be compared and filtered.
|
|---|
| 11 | * @param {T[]} secondArr - The array containing elements to be excluded from the first array.
|
|---|
| 12 | * Each element in this array will be checked against the first array, and if a match is found,
|
|---|
| 13 | * that element will be excluded from the result.
|
|---|
| 14 | * @returns {T[]} A new array containing the elements that are present in the first array but not
|
|---|
| 15 | * in the second array.
|
|---|
| 16 | *
|
|---|
| 17 | * @example
|
|---|
| 18 | * const array1 = [1, 2, 3, 4, 5];
|
|---|
| 19 | * const array2 = [2, 4];
|
|---|
| 20 | * const result = difference(array1, array2);
|
|---|
| 21 | * // result will be [1, 3, 5] since 2 and 4 are in both arrays and are excluded from the result.
|
|---|
| 22 | */
|
|---|
| 23 | declare function difference<T>(firstArr: readonly T[], secondArr: readonly T[]): T[];
|
|---|
| 24 |
|
|---|
| 25 | export { difference };
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.