April 8--class notes--js built-in objects

Source: Internet
Author: User

JavaScript Day8

First, JS built-in objects

    1. 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) ...

    1. 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

    1. 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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.