JavaScript Day8
First, JS built-in objects
- Strings string
A) attribute length: The number of characters, whether ASCII or Unicode, is 1 characters
b) Query method:
I. CharAt: Find characters based on index location, can be replaced by [index] (except for old IE)
II. charCodeAt: Find character encoding based on index location
III. INDEXOF: Finds the first occurrence based on character (string), returns 1 if not found, or finds from scratch when the second starting position is not specified, and if specified starts from the specified position
Iv. lastIndexOf: Find the last occurrence based on character (string)
c) Uppercase and lowercase conversions: tolowercase, toUpperCase
d) Interception method:
I. SUBSTR: The parameter represents the starting position (support Countdown) and the Intercept quantity (optional, if not provided, intercept to the end)
II. SUBSTRING: The parameter represents the starting position (no reciprocal support) and the end position (optional, if not provided, intercept to the end, does not support reciprocal), has automatic switching capability
Iii. slice: Parameters indicate starting position (support countdown) and end position (optional, if not provided, intercept to end, support reciprocal), no automatic switching capability
E) Split method: Split
f) static method fromCharCode: Not using object access, but using the method of type name access, can be regarded as the inverse method of charCodeAt
g) Other methods: Mostly add HTML tags for strings, such as: Link (add link a tag), bold (add B tag) ...
- Arithmetic class math: All static properties, methods, without creating an object
A) method of operation: ABS, exp, pow, sqrt
b) Trigonometric methods: sin, cos, etc., note the use of radians (Math.PI equals 180 degrees)
c) Rounding: Differences between ceil, floor, round, and tofixed of parseint and number classes
d) Other: Max, min, log, random; formula that produces a random integer of the specified range
- Dates class Date
A) Create: Var d=new Date ();
I. No parameters: System time for the current client
Ii. parameters of a number type: milliseconds to differ from the base time (1970-01-01 00:00:00.000 GMT)
III. 2 or more than 2 number type parameters: year, month (0--11), day, time, minute, second, millisecond, respectively, in order
Iv. A String type parameter: Gets the datetime in string if the format is recognized, for example: "1999-01-02 11:22:33"
b) Description: The date type has the ability to automatically adjust to the correct date
C) method: mainly divided into getxxx (used to get the date time of the part), setxxx (used to set the date time of the section)
April 8--class notes--js built-in objects