Built-in objects in JavaScript

Source: Internet
Author: User

1.Date Date Object

(1) Syntax: var mydate=new Date ();

(2) Parameter description: MyDate becomes a Date object and has an initial value: current time (current computer system time).

(3) Access method syntax:< date objects >.< methods >;

(4) A common way to process time and dates in a Date object:

(5) Note:get/settime () Returns/sets the time, in milliseconds;

Time delayed 1 hours, that is: "X.settime (X.gettime () + 60 * 60 * 1000);"

2.String String Object

(1) Syntax: var stringobject= "I Love javascript!";

(2) Properties of the access string:stringobject.length; Gets the length of the string; note : Spaces also belong to one character

(3) How to access the string:

3_1:stringobject. toUpperCase ();//Convert the lowercase letter of the string to uppercase;

3_2:stringobject. toLowerCase ();//Convert the string capital letters to lowercase;

3_3:stringobject. charAt (index);//returns the character at the specified position; Note : 1. The subscript for the first character in the string is 0. The subscript for the last character is the string length minus one (string.length-1). 2. If the parameter index is not between 0 and String.length-1, the method returns an empty string.

3_4:stringobject. indexOf (substring, startpos);//Returns the position where the specified string appears; Note: the 1.indexOf () method is case-sensitive. 2. If the string value that you want to retrieve does not appear, the method returns-1.

3_5:stringobject. Split (separator,limit);//string segmentation; Note: If you use an empty string ("") as a separator, then each character in the Stringobject will be split between them.

                    

              

3_6:stringobject. substring (Starpos,stoppos)//extract the string; Note: 1. The returned content is all characters from start (the character containing the start position) to stop-1, with a length of stop minus start. 2. If the parameter start is equal to stop, then the method returns an empty string (that is, a string of length 0). 3. If start is larger than stop, the method will exchange the two parameters before extracting the substring.

3. The remaining built-in objects are shown in link http://www.ibm.com/developerworks/cn/web/wa-objectsinjs-v1b/#list2 

Built-in objects in JavaScript

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.