1.URI method
encodeURI () and encodeURIComponent () encode the URI
encodeURI () does not encode special characters that are part of the URI, such as colons, forward slashes, greetings, well words, etc.
encodeURIComponent () encodes any non-standard characters
2.eval () Method: Interpreting code strings in Parameters
Copy Code code as follows:
var msg = "Hello World";
Eval ("Alert (msg)"); "Hello World"
3.Math objects
MATH.E the value of E in mathematics
Value of math.piπ
Square root of Math.sqrt2 2
Absolute value of math.abs (num) num
Num power of MATH.EXP (NUM) E
The natural logarithm of Math.log (num) num
N-Power of Math.pow (num,n) num
Square root of math.sqrt (num) num
Anti-cosine value of Math.acos (x) x
Math.asin (x) x's Inverse chord value
Math.atan (x) x's tangent value
Math.atan2 (y,x) y/x tangent value
Cosine of Math.Cos (x) x
Sine value of Math.sin (x) x
Tangent of Math.tan (x) x
4.min () and Max () methods
Copy Code code as follows:
var max = Math.max (3,45,67,32);
Alert (max); 67
var min = math.min (2,46,74);
Alert (min); 2
5. Decimal rounding to Integer method
Math.ceil () rounded up
Math.floor () Round down
Math.Round () rounded
Copy Code code 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 random () method returns a random number between 0~1, excluding 0 and 1
Take a random number formula in a range:
Random number = Math.floor (math.random * total + First value)//total = second value-First value
Copy Code code as follows:
//take-in-range random number function
function Selectfrom (lowervalue,uppervalue) {
var count = Uppervalue-lowervalue + 1;
Return Math.floor (Math.random () * Count +lowervalue);
}
var num = selectfrom (2,10);
Alert (num);//number between 2~10 (including 2 and ten)