First, the Math object
Math object: JS provides some of the math-related use methods
Math.ceil () rounding up
Math.floor () down rounding
Math.Round () rounding
Math.random () generates a random number from 0 to 1, which can be equal to 0 and not equal to 1
0 <= Math.random () < 1
Math.max (x, y) Gets the maximum value in x and y
Math.min (x, y) Gets the minimum value between x and y
Math.pow (x, y) Gets the Y-power of X (the Y-square)
Ii. Judging the type of data
Use the typeof provided by JS to get the data type of the variable
1 typeof (variable)
2 typeof variables
Iii. Conversion of data types
Convert numbers to Strings
1 number + " implicit conversion--" JS yourself convert data types
2 String (number) display Transform--"We did it ourselves."
3 number. toString ()
Convert a string to a number
1 + string with numeric content
2 Number (string with numeric content)
3 parseint () converted to integers
Convert parsefloat () to decimal
Convert to Boolean type
True False
1 !! Data -Implicit conversions
2 Boolean (data) display conversion
Iv. If...else
Syntax structure:
if (conditional expression) {
Code to execute when a conditional expression is set
} else {
Code that executes when a conditional expression is not valid
}
Five, logical operators
Function: Connect multiple conditional expressions
and && : requires multiple expressions to be set up at the same time
or | | : requires an arbitrary expression to be established
Non -! : Take counter
Six or three-tuple operator
Syntax structure:
Conditional expression? Data returned when an expression is formed: data returned by an expression that is not immediately
Seven, the Judgment Operator (ii)
= = Broad equals, compares the contents of two data
= = = Strictly equals, the comparison is content and type
VIII. special types in data types
Null represents an empty complex Type (object)
Undefined not defined
In JS, null,undefined,0, "", False,nan all mean false
Exercises:
JavaScript Basics 2