(i) Convert to string
Copy Code code as follows:
X + ""
ToString ()
String ()
A function is converted to a string that typically outputs a function body, but can override its ToString method
(ii) conversion to digital
Copy Code code as follows:
parseint (), parsefloat ()
Use number (), do not add new before, so it is converted to an object.
Participate in mathematical operations (except addition)
+ X: Note that this is not an addition
(iii) conversion to Boolean value
Automatic conversion: If statements, | |,&&,! and other logical judgments will automatically convert an expression to a Boolean value in the environment
Cast: Use!!, use Boolean (), do not add new before, so it is converted to an object.
(iv) Conversion to object
Direct new+ Object Name
(v) Summary
All types have: object names (variables to be converted) conversion methods, as well as some of their own independent skills.
JS type conversion, you can refer to the following figure: