1. URI Method
EncodeURI () and encodeURIComponent () encode the URI
EncodeURI () does not encode special characters belonging to the URI, such as colons, forward slashes, hello, and well characters.
EncodeURIComponent () Will encode any non-standard characters
2. eval () method: interpreted the code string in the Parameter
Copy codeThe Code is as follows:
Var msg = "hello world ";
Eval ("alert (msg)"); // "hello world"
3. Math object
The value of E in Math. e mathematics
Math. PI π Value
The square root of Math. SQRT2 2
Math. abs (num) num absolute value
Num power of Math. exp (num) e
Math. log (num) num's natural logarithm
Math. pow (num, n) num n power
Math. sqrt (num) num, square root
Inverse cosine of Math. acos (x) x
Inverse sine value of Math. asin (x) x
The arc tangent value of Math. atan (x) x
The arc tangent value of Math. atan2 (y, x) y/x
Cosine of Math. cos (x) x
Sine value of Math. sin (x) x
Math. tan (x) x tangent
4. min () and max () Methods
Copy codeThe Code is as follows:
Var max = Math. max (3,45, 67,32 );
Alert (max); // 67
Var min = Math. min (2,46, 74 );
Alert (min); // 2
5. Round decimal places to the integer Method
Math. ceil () rounded up
Math. floor () rounding down
Math. round () Rounding
Copy codeThe Code is as follows:
Alert (Math. ceil (25.1); // 26
Alert (Math. ceil (25.5); // 26
Alert (Math. ceil (25.9); // 26
Alert (Math. round (25.1); // 25
Alert (Math. round (25.5); // 26
Alert (Math. round (25.9); // 26
Alert (Math. floor (25.1); // 25
Alert (Math. floor (25.5); // 25
Alert (Math. floor (25.9); // 25
6. the return value of the random () method is between 0 and 0 ~ A random number of 1, excluding 0 and 1
Get a random number formula in a certain range:
Random Number = Math. floor (Math. random * Total number + first value) // total number = second value-first value
Copy codeThe Code is as follows:
// Random number function within the range
Function selectFrom (lowerValue, upperValue ){
Var count = upperValue-lowerValue + 1;
Return Math. floor (Math. random () * count + lowerValue );
}
Var num = selectFrom (2, 10 );
Alert (num); // between 2 and ~ Number between 10 (including 2 and 10)