Any

The Any data type is a dynamic data type that can hold Any value. TypeScript throws compile time errors if you assign a string-type variable to an integer-type variable. If you are unsure about what value a variable will hold, and you would like to opt out of compiler checking for the type in the assignment, you can use the Any data type:

let mixedList:any[] = [1, "I am string", false]; 
mixedList [2] = "no you are not";

Here, we used an array of the any type so that it can hold any type, such as number, string, and boolean.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset