
上QQ阅读APP看书,第一时间看更新
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 variable to an integer variable. If you are not sure about what value a variable is going to hold and you would like to opt out of compiler-checking for the type in the assignment, you can use the any data type:
var 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 numbers, strings, and booleans.