- Learning Ionic(Second Edition)
- Arvind Ravulavaru
- 56字
- 2021-07-02 23:24:24
Variable typing
In vanilla JavaScript, we would do something like this:
x = 20;
// after a few meaningful minutes
x = 'nah! It's not a number any more';
But in TypeScript, we cannot do as shown in the preceding code snippet, the TypeScript compiler would complain as we are modifying the variable type at runtime.