title: typescript set of objects
body: <p>I am new in angular2 and typescript. I have a problem in creating an unique collection like Set&lt;>. 
  I want to avoid duplicate objects in a collection, for that purpose, try to use 
  a set dataType like following code:</p>
  
  <pre><code>private cardItems = new Set&lt;MyBean&gt;([]);
  </code></pre>
  
  <p>MyBean is an object.</p>
  
  <pre><code>export class MyBean  {
  
    id:integer
    ownerId:integer
    ownerName:string
    img: string;
  
  constructor() {
  
  }
  public equals(obj: MyBean) {
      console.log(obj.id);
      if (this.id == obj.id) {
          console.log(obj.id);
          return true;
      }
      if (obj == null)
          return false;
  
      return true;
  }
  
  public hashCode(obj: MyBean) {
      return obj.id
  }
  </code></pre>
  
  <p>}</p>
  
  <p>but equals and hashCode does not run in this way.and I have duplicate objects in set.</p>
  
  <p>What is the solution for implementing Set?</p>
  
  <p>Many thanks</p>