Javascript has two data types:
(1) converting the entire value from one type to another (called Basic data type conversion)
(2) extract another type of value from one value and complete the conversion
Three methods for converting basic data types:
1. Convert to string type: string (); for example, the result of string (678) is "678"
2. Convert to numeric type: Number (); for example, the result of number ("678") is 678.
3. Convert to boolean: Boolean (); for example, Boolean ("AAA") returns true
How to extract another type of value from one value:
1. Extract the integer parseint () in the string. For example, the result of parseint ("123 Zhang") is 123.
2. Extract the floating point: parsefloat () in the string. For example, the result of parsefloat ("0.55 Zhang") is 0.55.
3. Execute a javascript stringCode: Eval (); example: Zhang = eval ("1 + 1") Result: Zhang = 2
Note: Number and string functions are special functions. In the JS engine, they will automatically determine whether they are called as constructors or normal calls. Therefore, they can use the new keyword, it can also be called directly as a function.