[typescript] Typescript digital enumeration string enumeration, Typescript any type

Numerical enumeration

enum myenum { up = 10 , down = 8 , left = 6 , right = 4 }

Description: The value of the enumeration member is a number representing a numerical enumeration

Numeric Enums: Numbers for enum member values

string enumeration

enum myenum { up = 'up' , down = 'down ', left = 'left ', right = 'right ' }

String enumeration: a string of enumeration member values

Note: String enumeration has no self-growth behavior. Each member of string enumeration must have an initial value

Typescript any type

let obj:any = { x:0 }

describe:

It is not recommended to use any, which will turn typescript into acyscript and lose the advantage of type protection

Because when the value type is any, you can perform arbitrary operations on the value and there will be no code prompts

any situation:

Declare a variable without providing a type nor a default value

No type is added to the function parameters
. Note: the any type is not recommended for use in work. Novices can use it to help quickly skip the ts validation and realize the business. Some events are slowly changing any to a normal interface type type.

Novices at work can use this to increase their own development speed without having to think about how to define various excuses and types

Guess you like

Origin blog.csdn.net/m0_64494670/article/details/129270253