Test for an array being subset of another master array
So the key here is that I value code that's obvious to others.

Someone else is likely to try to stuff duplicate elements in unless it requires a type refactor; making const masterSet: Set&lt;number&gt; and using that throughout the code is a Good Idea. That "someone else" can often be you two months down the line, too. 

In this case I would not say that the point of this length comparison is obvious; it will work but it takes some thinking -- that is why it has bugs with duplicate elements. In this case I would write something  which I find more straightforward like,



function isSubsetOf&lt;x&gt;(sub: Iterable&lt;x&gt;, sup: Set&lt;x&gt;): boolean {
  for (const x of sub) {
    if (!sup.has(x)) {
      return false;
    }
  }
  return true;
}


I am also hinting through the type system how this function works by insisting that the subset is any iterable -- so I must be iterating through it.

With a restriction to an array and a set, one can get a little swankier by using the reduce function,

function isSubsetOf&lt;x&gt;(sub: Array&lt;x&gt;, sup: Set&lt;x&gt;): boolean {
  return sub.reduce((acc, x) =&gt; acc &amp;&amp; sup.has(x), true);
}


but probably not all other readers will find that as intuitive as I do, and the former has slightly better runtime characteristics on very large lists that are obviously not subsets.