Array object:
Property:
The length of the array is obtained.
Method:
. Concat () connect the contents or arrays to form a new array;
. Join (n) consists of a string of each entry of an n-connected array, which can be an empty string;
. Pop () deletes the last item of data in the array and returns the deleted data;
. push () returns the length of the new array by adding new content at the end of the array
. Reverse () flips the array;
String Object
Property:
. length gets the length of the string.
Method:
. charAt (n) find the character at position N (index).
. charCodeAt (n) Find the encoding of the character at the index location: a=97,a=65.
. IndexOf ("M") finds the index of the first occurrence of the character m in the string, if no return-1 is found.
. LastIndexOf ("M") finds the index of the last occurrence of the character m in the string, if no return-is found.
. Split ("n") splits the string with the character n and returns an array with an empty string when each character is split, and if the character is not in the string, the array is also returned.
. substr (N,m) intercepts the string from the position where the index is n, intercepts the M-character, and if there is only one parameter n, it is intercepted from N and truncated to the last.
. substring (n,m) intercepts the string, starting at the position where the index is n, intercepting the M-character (m not marrying); If there is only one parameter n, it is intercept from N and intercept to the last.
. toLowerCase () Converts the letters in a string to lowercase.
. toUpperCase () Converts the letters in a string to uppercase.
Math Object
Method:
Math.pow (n,m) n's m-th square.
Math.Abs (n) n the distance from the origin (the absolute value of N).
Math.Round (n) Rounds rounding.
Math.floor (n) floor function (rounded down).
Math.ceil (n) Ceiling function (rounding up).
Math.random () returns a random number of 0-1 (less than 1).
Note: [N,m] random number in order to be able to fetch n,m Math.floor (Math.random ()) * (m-n+1) +n).
Special characters
\ r Enter
\ nthe line break
Date object var date = new Date ();
Method:
. toLocaleString () Displays the time in the current local format.
Date.getfullyear () Gets the year of the date object.
Date.getmonth () Gets the month (0-11) corresponding to 1-12 months.
Date.getdate () Gets the date.
Date.gethours () Gets the hour.
Date.getminutes () Get minutes
Date.getseconds () gets how many seconds
Date.getmilliseconds () Number of milliseconds
Date.getday () Gets the day of the Week (0-6) corresponding to Sunday to Saturday.
Date.gettime () millisecond value (timestamp) from 1970 onwards to the time date
Date.setfullyear Set Year
...
...
Mouse events:
OnClick Mouse click event
onMouseOver Mouse on
onMouseOut Mouse Away
OnDblClick Double-click event
onmousedown mouse button down
OnMouseUp Mouse Lift
OnMouseMove Mouse Movement
Form events:
Onfocus Get Focus
Onblur loses focus
OnSubmit Submit Event
When onchange changes,
OnReset Reset Event
Keyboard events:
onkeyup button to lift up
OnKeyDown Press the button
onkeypress Keyboard Press Next time
Window events:
OnLoad event (executes immediately after page load completes)
Two methods
1, <script>window.onload= "Init";</script>//init for the function of the name
2, <body onload= "init ()" ></body>//init () is a complete function
Event :
Save information about when an event occurs
Event.clientx: The coordinates of x when the event occurs
Event.clienty: Coordinates of y when an event occurs
Event.target Event Source
Note: An event must be passed to a function by using an argument to use
Var obj=document.createelement ("tag name");
Document.body.appendChild (obj);
Window Object
Alert ()
Confirm () Pop-up window display OK cancel
Prompt () input box
window. Open ("link", "Name", "Settings");
1. Width
2. Height
3. Left
4. Top
5, scrollbars yes no scroll bar
6. toolbar Yes No toolbar
7. Location bar (browser)
8, Close () only the window opened by JS code can be closed
Each setting property is separated by ",", 7 and 8 require user permission
Timer:
Disposable Timers:
Var name1=window.settimeout ("JS code", Time t)
Execution: After the time t executes the JS code.
Period: Millisecond calculation.
repeatability Timer:
Var name2=window.setinterval ("JS code", Time t)
Execution: once per time t
Cycles are calculated in milliseconds
Clear timer: Must give the timer a name
Disposable Timer windowcleartimeout (name1);
repeatability timer window.clearinterval (name2);
JS important built-in objects