判定偶數
function collect_all_even(collection) { return collection.filter(item => item%2 == 0); }
兩個集合的交集
function get_intersection(collection_a, collection_b) {
return collection_b.filter(item => collection_a.includes(item))
}
兩個集合的並集
function get_union(collection_a, collection_b) { return new Set([...collection_a,...collection_b]); }
升序排序
arr.sort((arr1, arr2) => arr1 - arr2)