numeric types are automatically converted to strings when the data for a string, numeric type is additive.
When the IF condition is inside, the result is automatically converted to a Boolean type of data.
1 <script type= "Text/javascript" >2 var a = 1; 3 var b = ' 2 '; 4 Console.log (typeof(a+b)); // string5 </script>
To force type conversions:
Conversion functions |
Meaning |
Number () |
Forcing other types of data to be converted to numeric type |
parseint () |
Forcing other types of data to be converted to integers |
Parsefloar () |
Force other types of data to be converted to number type (decimal) |
String () |
Forcing other types of data to be converted into strings |
Boolean () |
Convert other types of data to Boolean |
1 <script type= "Text/javascript" >2 varnull; 3 Console.log (parseint (Vone)); // NaN 4 </script>
JavaScript operator.
1. Arithmetic operators
1 <script type= "Text/javascript" >2 var a = ten; 3 var b = a++; 4 var c =--b; 5 var d = C + + + + +; 6 var e = d-----D; 7 Alert (e); // 2 8 </script>
2. Assignment operators
=,+=,-=,*=,/=,%=
3. Comparison operators
>,<,==,===,!=,!===,>=,<=
4. Logical operators
&&,| |,!
5. Ternary operators
Condition ==true? True:false
1 <script type= "Text/javascript" >2 var a = ten; 3 var b = Ten; 4 A+b = = 20? Alert (' True '): Alert (' false '); 5 </script>
JavaScript process statements
Note: If you use else if the else if is in the middle there is a space. The For in () loop can iterate over an array, an object
JavaScript Data type conversions