Answers for "javascript compare sets"

0

javascript compare sets

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

alert(eqSet(a, b)); // true

function eqSet(as, bs) {
    if (as.size !== bs.size) return false;
    for (var a of as) if (!bs.has(a)) return false;
    return true;
}
Posted by: Guest on May-09-2021

Code answers related to "Javascript"

Browse Popular Code Answers by Language