List subsets

If you want to know that a list belongs to another list, you can use the isSubset() method:

const myList = List.of(
List.of(1, 2, 3),
List.of(4, 5, 6),
List.of(7, 8, 9)
);
const isSubset = List.of(1, 4, 7)
.isSubset(myList.flatten());

console.log('isSubset', isSubset);
// -> isSubset true

The myList collection is a list of lists. So once you flatten it, you can pass it to the isSubset() method when it's called on the list: List.of(1, 4, 7). This returns true because myList contains each of these values.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.135.198.49