💾set.isEqualTo()

JSvalueobjectbuilt-inSetextension ⟩ .isEqualTo()

// isEqualSets(a,b)
function isEqualSets(a, b){
    if (a.size !== b.size) return false;
    return Array.from(a).every(elem => b.has(elem));
}

// setA.equal(setB)
Set.prototype.equal = function(setB){
    return isEqualSets(this, setB);
}

Last updated