get type of object typescript not string code example
Example 1: typescript object type
//is not strict mode
let endedCoord: {x: number, y: number} = {
x: -1,
y: -1,
}
Example 2: type gurad
1) Type guards narrow down the type of a variable within a conditional block.
2) Use the 'typeof' and 'instanceof operators to implement type guards in the
conditional blocks.
//example(typeof)
if (typeof a === 'number' && typeof b === 'number') {
return a + b;
}
(instanceof)
if (job instanceof detail){
jobless = false ;
}