type assertion in TypeScript

type assertion is like a type cast in other languages, but performs no special checking or restructuring of data. It has no runtime impact, and is used purely by the compiler. 


let message;
message=’abc’;
let endWithC=(<string>message).endsWith(‘c’);
let alternatveWayC=(<message as string>message).endsWith(‘c’);

Comments

Popular Posts