mirror of
https://github.com/toss/es-toolkit.git
synced 2024-11-24 03:32:58 +03:00
722 B
722 B
isSubset
Checks if the subset
array is entirely contained within the superset
array.
Signature
function isSubset<T>(superset: T[], subset: T[]): boolean;
Parameters
superset
(T[]
): The array that may contain all elements of the subset.subset
(T[]
): The array to check against the superset.
Returns
(boolean
): Returns true
if all elements of the subset
are present in the superset
, otherwise returns false
.
Examples
const superset1 = [1, 2, 3, 4, 5];
const subset1 = [2, 3, 4];
isSubset(superset1, subset1);
// Return true
const superset2 = ['a', 'b', 'c'];
const subset2 = ['a', 'd'];
isSubset(superset2, subset2);
// Return false