JavaScript there are two types of data conversion methods: one is to convert the entire value from one type to another data type (called basic Data type conversion ), another method is to extract another type of value from one value and complete the conversion.
basic data type conversion three methods:
1. convert to string type: string (). For example, the result of string (678) is "678"
2. convert to numeric: Number (). For example, the result of number ("678") is 678
3. convert to boolean: Boolean (); example: Boolean ("AAA ") the result is true
extract another type of value from one value. method:
1. extract the integer in the string: parseint (); example: parseint ("123 Zhang ") the result is 123
2. extract the floating point in the string: parsefloat (); example: parsefloat ("0.55 Zhang ") result 0.55
3. Execute a segment represented by a stringJavascriptCode: Eval (); example: Zhang = eval ("1 + 1") Result: Zhang = 2
Both functions are fault tolerant. For example, "123abc" will change to 123.