Date Day Object
Date objects can store any date and can be accurate to milliseconds (1/1000 seconds).
Define a Time object:
Note : Use the first letter of the keyword New,date () to capitalize.
Makes udate a Date object and has an initial value: The current time (current computer system time).
If you want to customize the initial values, you can use the following methods:
var d = new Date (1); October 1, 2012 var d = new Date (' OCT 1, 2012 '); October 1, 2012
We'd better use the "method" described below to strictly define the time.
access method Syntax:"< date objects >.< methods >"
Common methods for processing time and dates in a Date object:
return/Set Time method
get/settime () Returns/sets the time, in milliseconds, to calculate the number of milliseconds from January 1, 1970 0 o'clock to the date the Date object refers to.
If the current date object's time is postponed by 1 hours, the code is as follows:
<script type= "Text/javascript" > var mydate=new Date (); document.write ("Current Time:" +mydate+ "<br>"); Mydate.settime (Mydate.gettime () + * + *); document.write ("Delay One hour:" + mydate);</script>
String String Object
Use the toUpperCase () method of the string object to convert the string lowercase letters to uppercase:
Use the toLowerCase () method of the string object to convert the string uppercase letters to lowercase:
Returns the character at the specified position
The CharAt () method returns the character at the specified position. The returned character is a string of length 1.
Grammar:
Stringobject.charat (Index)
Parameter description:
Note : 1. The subscript for the first character in a 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.
Returns the location of the first occurrence of the specified string
The IndexOf () method returns the position of the first occurrence of a specified string value in a string.
Grammar
Stringobject.indexof (substring, startpos)
Parameter description:
Description
1. The method will retrieve the string stringobject from beginning to end to see if it contains substring substring.
2. Optional parameters, starting from the startpos position of the stringobject to find substring, if no this parameter will be found from the beginning of the Stringobject.
3. If a substring is found, the position of the first occurrence of the substring is returned. The character position in Stringobject is starting at 0.
Note: The 1.indexOf () method is case-sensitive.
String Split Split ()
Knowledge Explanation:
The split () method splits a string into an array of strings and returns this array.
Syntax:
Stringobject.split (Separator,limit)
parameter Description:
Note: If you use an empty string ("") as a separator, then each character in the Stringobject will be split.
Extract string substring ()
The substring () method is used to extract the character of a string intermediary between two specified subscripts.
Grammar:
Stringobject.substring (Starpos,stoppos)
Parameter description:
Attention:
1. The returned content is all characters from start (the character containing the start position) to Stop-1, whose length is 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.
Extracts the specified number of characters substr ()
The substr () method extracts a specified number of strings from the string that start at the startpos position.
Grammar:
Stringobject.substr (Startpos,length)
Parameter description:
Note: If the parameter startpos is a negative number, the position is calculated from the end of the string. That is,-1 refers to the last character in the string, 2 refers to the second-lowest character, and so on.
If Startpos is negative and the absolute value is greater than the string length, Startpos is 0.
Math Object Properties
Math Object method
Rounding up Ceil ()
Math.ceil (x)
Take down the entire floor ()
Math.floor (x)
Rounding Round ()
Math.Round (x)
Random number ()
Math.random ();
The random () method returns a random number between 0 and 1 (greater than or equal to 0 but less than 1).
Array Object
Array method:
Array Connection concat ()
The Concat () method is used to concatenate two or more arrays. This method returns a new array without changing the original array.
Grammar
Arrayobject.concat (array1,array2,..., Arrayn)
Parameter description:
Specify delimiter join array element join ()
The join () method is used to put all the elements in an array into a string. The elements are delimited by the specified delimiter.
Grammar:
Arrayobject.join (delimiter)
Parameter description:
Reverse array element order reverse ()
The reverse () method reverses the order of the elements in the array.
Grammar:
Arrayobject.reverse ()
Note: This method changes the original array without creating a new array.
Selected element Slice ()
The slice () method returns the selected element from an existing array.
Grammar
Arrayobject.slice (Start,end)
Parameter description:
1. Returns a new array containing the elements from start to end (excluding the element) in the Arrayobject.
2. The method does not modify the array, but rather returns a sub-array.
Attention:
1. Negative values can be used to select elements from the tail of the array.
2. If end is not specified, then the slice () method selects all elements from start to the end of the array.
3. String.slice () is similar to Array.slice ().
Sort Array ()
The sort () method causes the elements in the array to be arranged in a certain order.
Grammar:
Arrayobject.sort (method function)
Parameter description:
1. If the < method function is not specified, it is sorted in Unicode code order.
2. If you specify the < method function, then sort by the < method function > The sorting method specified.
Myarray.sort (SortMethod);
Note: The function compares two values and returns a number that describes the relative order of the two values. The comparison function should have two parameters A and B with the following return values:
A return value of <=-1 indicates that A appears before B in the sorted sequence.
If the return value >-1 && <1, then A and B have the same sort order.
A return value of >=1 indicates that A appears after B in the sorted sequence.
JavaScript built-in objects (string, array, date processing)