JSFiddle - React, Tailwind, and code Playground

JavaScript

var a = [1, 2, 3],
    b = [3, 2, 1, 4];
diff(a, b);

function diff(arr1, arr2) {
    var obj = {}, matched = [],
        unmatched = [];
    for (var i = 0, l = arr1.length; i < l; i++) {
        obj[arr1[i]] = (obj[arr1[i]] || 0) + 1;
    }
    for (i = 0; i < arr2.length; i++) {
        var val = arr2[i];
        if (val in obj) {
            matched.push(val);
        } else {
            unmatched.push(val);
        }
    }
    // Here you can find how many times an element is repeating.
    console.log(obj);
    // Here you can find what are matching.
    console.log(matched);
    // Here you can check whether they are equal or not.
    console.log('Both are equal ? :' + 
    matched.length === a.length);
    // Here you can find what are different  
    console.log(unmatched);
}