> For the complete documentation index, see [llms.txt](https://lochiwei.gitbook.io/web/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://lochiwei.gitbook.io/web/js/val/builtin/set/set-extension/set.isequalto.md).

# set.isEqualTo()

[JS](/web/js.md) ⟩ [value](/web/js/val.md) ⟩ [object](/web/js/val/obj.md)⟩ [built-in](/web/js/val/builtin.md) ⟩ [Set](/web/js/val/builtin/set.md) ⟩ [extension](/web/js/val/builtin/set/set-extension.md) ⟩ .isEqualTo()&#x20;

{% tabs %}
{% tab title="💾 程式" %}

* replit ⟩ [Set Equality](https://replit.com/@pegasusroe/Set-Equality#index.js) (old code)

```javascript
// 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);
}
```

* :point\_right: [Set extension](/web/js/val/builtin/set/set-extension.md#fan-li)&#x20;
  {% endtab %}

{% tab title="📘 手冊" %}

* array.[every](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/every)(), [Array.from](https://developer.mozilla.org/zh-TW/docs/Web/JavaScript/Reference/Global_Objects/Array/from)()
* [Set](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set#instance_methods)
  {% endtab %}

{% tab title="🗣 討論" %}

* [comparing ECMA6 sets for equality](https://stackoverflow.com/questions/31128855/comparing-ecma6-sets-for-equality)
  {% endtab %}
  {% endtabs %}
