Type Assertion

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. if you don’t assign value at the time of declaration of let keyword you don’t get intellisense after dot place variable name.

let mm;
mm = “sagar”;
let endswith = (mm).endsWith(“r”);

let mm;
mm = “sagar”;

let endswith = (mm).endsWith(“r”);
let alternative = (mm as string).endsWith(“r”);

Type Assertion

Below is the video explain TypeAssertion.

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *