How to check the object type on runtime in TypeScript? : <p>I'm trying to find a way to pass an object to function in and check it type in a runtime. This is a pseudo code:</p>

<pre><code>func(obj:any){
  if(typeof obj === "A"){
    // do something
  }
  else if(typeof obj === "B"{
    //do something else
  }

}
 a:A;
 b:B;
 func(a);
</code></pre>

<p>But typeof is always return "object" and I could not find a way to get the real type of "a" or "b". The instanceof did not work either and return the same.
Any idea how to do it in a TypeScript?</p>

<p>Thank you for your help!!!</p>
