在网上找到这样一个方法
function handleIncludes(childArr, fatherArr) {
return childArr.every(v => fatherArr.includes(v));
}
let a = [1,2]
let b = [1,2,3]
let target = handleIncludes(a, b); // true
但是他有个问题,
let c = [2,2]
let target = handleIncludes(c, b); // true
这里应该false 应该brr没有两个2
希望有个高性能的简洁写法判断出真子集,大佬有写法吗?
可以试试,排序后转换成字符串比较。