In the vue project, how to filter out the common elements in the three arrays or how to filter out different elements can also be done.

    var a = ["1", "2", "3"]
    var b = ["2", "3"]
    var c = ["4", "5","2"]
    
Jan.10,2022

a.filter (I = > b.some (_ I = > _ I = I) & & c.some (_ I = > _ I = i))


let a = new Set([1, 2, 3]);
let b = new Set([4, 3, 2]);

// 
let union = new Set([...a, ...b]);
// Set {1, 2, 3, 4}

// 
let intersect = new Set([...a].filter(x => b.has(x)));
// set {2, 3}

// 
let difference = new Set([...a].filter(x => !b.has(x)));
// Set {1}

let a = ['1', '2', '3', '5'];
let b = ['2', '3', '5'];
let c = ['4', '5','2'];

console.log(getCommon(a, b, c));    // ['2', '5']

function getCommon(arrA, arrB, ...others) {
    if (others.length == 0) {
        return _two(arrA, arrB);
    } else {
        return getCommon(_two(arrA, arrB), ...others)
    }

    // 
    function _two(a, b) {
        return a.filter(el => b.includes(el));
    }
}

fn accepts any array that needs to be filtered

  https://www.cnblogs.com/small., this can be handled with PHP, jquery does not know 

Menu