String manipulation
var s= "ABCDEFG"
S.tolowercase () Turn lowercase
S.touppercase () Turn capital
S.substring (2,5) index subscript starting from 0 intercept 5 bits starting from the 3rd
S.substr (2,5) Ibid.
Suppose s= "A,b,c,d,e,f,g"
S.split (', ') has commas separated by commas a string of several elements an element
For example:
1 var " a,b,c,d,e,f,g " ; 2 var ss = S.split (','); 3 for (var0; i < ss.length; i++) 4 {alert (ss[i]);}
View Code
S.length length
S.indexof ("World") find the first world where there is no return-1
Time-Date function
var d=new Date (); The current system time is seldom used because the user's computer time can be changed casually
var d=new date (1999,3,2) time format definition time is March 2, 1999
Get year D.getfullyear
Get Month D.getmonth ()
Get Day D.getdate ()
Get the day of the Week D.getday ()
Get hour Minute seconds d.gethours () d.getminutes () D.getseconds ()
Set year d.setfullyear ()
Mathematical functions
Go to Upper limit Math.ceil ()
Go to lower limit math.floor ()
Open Square math.sqrt ()
Rounding Math.Round ()
Random number Math.random () random number is between 0-1
To take a random number between 0-5
Math.ceil (5*math.random ())
Add a little bit of knowledge
S.match (REG) s represents a string of Reg representing a string of two matches equivalent to if in the S==reg
Event
OnClick Click Trigger
OnDblClick Double-click Trigger
onmouseover Move-in Trigger
onmouseout Move out Trigger
OnMouseMove Mouse on top move trigger
onchange content Change Trigger
Onblur Lose Focus Trigger
Onfocus Get Focus Trigger
onkeydown Button Press the trigger
onkeyup Button lift up trigger
onkeypress Release any letter key trigger but the system button is not recognized (for example: arrow function key)
JS string time number function operation event