(1) Convert to string
Converting a function to a string usually involves outputting the function body, but you can override its toString method
(2) Convert to numbers
Use Number() without adding new in front, so it will be converted into an object.
Participate in mathematical operations (except addition)
X: Note that this is not addition
(3) Convert to Boolean value
Automatic conversion: If statements, ||, &&, ! and other logical judgment environments will automatically convert expressions into Boolean values
Force conversion: use!!, use Boolean(), do not add new in front, so it will be converted into an object.
(4) Convert to object
Direct new object name
(5) Summary
Each type has: object name (variable to be converted) conversion method, as well as some independent skills.
JS type conversion, you can refer to the figure below: