1.math.random () function;
2.math.floor (x) returns the largest integer less than the parameter x, which is the rounding down of the floating-point number.
For example: The random itself only produces a decimal between (0~1), random () *10 meaning to produce a decimal between 0~10
3.Regular Expressions Regular expression: a regular expression is used to find certain words or patterns in a string.
For example: if we want to find in the string: Dog Chasing the cat, this string, we can use the following regular expression:/The/gi
How to use regular expressions:
/is the beginning of the regular expression.
The pattern we want to match.
/The end of the regular expression.
G means the global, which causes the pattern to return all matches in the string, not just one.
I mean when we are searching, ignoring the case mode;
Teststring.match (expression). The function of length is to return the number of and in the computed string;
4. Regular expression: Retrieves a numeric selector for a number in a string (for example, a number 9 through 0). In JavaScript, it's like this:/\d/g;
Add a plus sign (+) after the selection, for example:/\d+/g, allow this regular expression to match one or more numbers;
There are two numbers in this string, so the result is: 2;
5. We can also use regular expressions to select spaces in the preferred lookup string. Space characters: "", \ r (carriage return), \ n (newline), \ T (label), and \f (page break).
A regular expression of spaces looks like this:/\s+/g
In this string, there are 7 spaces, so the result of the regular expression retrieval is: 7;
6. Regular expression:/\s/g, which is used to retrieve all non-whitespace characters:
In this string, non-whitespace accounts for 49 strings, so the result of the retrieval is: 49;
2016.9.13 JavaScript Introductory six basic functions