typescript get the typeof a variable code example
Example: typescript check type of variable
if (fooOrBar instanceof Foo){
// TypeScript now knows that `fooOrBar` is `Foo`
}
if (fooOrBar instanceof Foo){
// TypeScript now knows that `fooOrBar` is `Foo`
}