First, a simple understanding of JS typeof, will return six types
That is, number string Boolen function object undefined is also six basic data types
There are probably several types of display type conversions:
Number () is converted to number type
string () is converted to string type
Boolean () converts to Boolean type
And so on tosting () paseint ( ) and other methods, need to say again is parseint ()
When you enter parseint (' 3242SFDA ') will return 3242
But input parseint (' sfda3242 ') returns Nan
That is, if the first character is not a number, Nan is returned, and it is important to note that the online tutorial also mentions
Implicit type conversions
Implicit type conversions are implicitly invoked when some operations are performed, such as Nmuber, as follows:
+ Call string () when there are stirng types on both sides
> < >= <= = = = # call number when both sides have number type ()
&& | | ! Call Boolean ()
++/--+/-/*/% call number ()
IsNaN () call number ()
= = = does not call
Above personal feeling the most important is the first two ,+ need to explain in a moment
The default is to call number (), but it detects if there is a string on both sides, and some uses string directly, but
Direct console input +string will return Nan can try to enter + ' ADFAA ' in console
Personal study records, if not, please correct me.
Implicit type conversion of JavaScript