Set ` |  (  A  â  B  )  âª  (  B  â  A  )  (A\setminus B)\cup(B\setminus A)  |  ![A Venn diagram where two circles overlap. The symmetric difference of A and B is the region contained by either circle but not both.](/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set/symmetricDifference/diagram.svg)  
[ ` A.union(B) ` ](/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set/union) |  ` Set ` |  A  âª  B  A\cup B  |  ![A Venn diagram where two circles overlap. The symmetric difference of A and B is the region contained by either or both circles.](/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set/union/diagram.svg)  
[ ` A.isDisjointFrom(B) ` ](/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set/isDisjointFrom) |  ` Boolean ` |  A  â©  B  =  â  A\cap B = \empty  |  ![A Venn diagram with two circles. A and B are disjoint because the circles have no region of overlap.](/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set/isDisjointFrom/diagram.svg)  
[ ` A.isSubsetOf(B) ` ](/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set/isSubsetOf) |  ` Boolean ` |  A  â  B  A\subseteq B  |  ![A Venn diragram with two circles. A is a subset of B because A is completely contained in B.](/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set/isSubsetOf/diagram.svg)  
[ ` A.isSupersetOf(B) ` ](/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set/isSupersetOf) |  ` Boolean ` |  A  â  B  A\supseteq B  |  ![A Venn diagram with two circles. A is a superset of B because B is completely contained in A.](/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set/isSupersetOf/diagram.svg)  
  
To make them more generalizable, these methods don't just accept ` Set `
objects, but anything that's  set-like  .

###  Set-like objects

All  set composition methods  require [ ` this ` ](/en-
US/docs/Web/JavaScript/Reference/Operators/this) to be an actual ` Set `
instance, but their arguments just need to be set-like. A _set-like object_ is
an object that provides the following:

  * A [ ` size ` ](/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set/size) property that contains a number. 
  * A [ ` has() ` ](/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set/has) method that takes an element and returns a boolean. 
  * A [ ` keys() ` ](/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set/keys) method that returns an [ iterator ](/en-US/docs/Web/JavaScript/Reference/Iteration_protocols) of the elements in the set. 

For example, [ ` Map ` ](/en-
US/docs/Web/JavaScript/Reference/Global_Objects/Map) objects are set-like
because they also have [ ` size ` ](/en-
US/docs/Web/JavaScript/Reference/Global_Objects/Map/size) , [ ` has() ` ](/en-
US/docs/Web/JavaScript/Reference/Global_Objects/Map/has) , and [ ` keys() `
](/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map/keys) , so they
behave just like sets of keys when used in set methods:

js

    
    
    const a = new Set([1, 2, 3]);
    const b = new Map([
      [1, "one"],
      [2, "two"],
      [4, "four"],
    ]);
    console.log(a.union(b)); // Set(4) {1, 2, 3, 4}
    

**Note:** The set-like protocol invokes the ` keys() ` method instead of [ `
[@@iterator]() ` ](/en-
US/docs/Web/JavaScript/Reference/Global_Objects/Set/@@iterator) to produce
elements. This is to make maps valid set-like objects, because for maps, the
iterator produces _entries_ but the ` has() ` method takes _keys_ .

[ Arrays ](/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array) are not
set-like because they don't have a ` has() ` method or the ` size ` property,
and their ` keys() ` method produces indices instead of elements. [ ` WeakSet
` ](/en-US/docs/Web/JavaScript/Reference/Global_Objects/WeakSet) objects are
also not set-like because they don't have a ` keys() ` method.

###  Set-like browser APIs

Browser **` Set ` -like objects ** (or "setlike objects") are [ Web API ](/en-
US/docs/Web/API) interfaces that behave in many ways like a ` Set ` .

Just like ` Set ` , elements