check var type ts code example
Example 1: typescript check type of variable
if (fooOrBar instanceof Foo){
// TypeScript now knows that `fooOrBar` is `Foo`
}
Example 2: typescript get type
if (typeof abc === "number") {
// do something
}
if (fooOrBar instanceof Foo){
// TypeScript now knows that `fooOrBar` is `Foo`
}
if (typeof abc === "number") {
// do something
}