Javascript_core, Math, Date
1. Regexp:regular expression, create the encapsulated regular expressions:
① Direct Volume: var reg=/reg/ig;②var reg=new RegExp ("Reg", "IG");
2. RegExp API:
① find each keyword and get location: var arr=reg.exec (str); default search from the beginning;
return value: arr: "keywords",1,1,2,$3 ... ";
Arr.index: This time to find the location of keywords;
Find: Reg.lastindex: Where to start next;
RegExp. $n: The nth grouping of the keywords;
3. Verification: Var bool=reg.test (str); returns a Boolean value;
4. Math:
①: Math.ceil (num), ② down: Math.floor (num), ③ rounded rounding: Math.Round (num), ④ rounded by any decimal place: n.tofixed (d); ⑤ Power: Math.pow (base, exponentiation); ⑥ Open Square: math.sq RT (num); ⑦ max: Math.max (value 1, value 2 ...) ); ⑧ Minimum Value: math.min (value 1, value 2 ...). ); ⑨ gets the maximum value in the array: Math.max.apply (Null,arr); 10 Gets the minimum value in the array: Math.min.apply (Null,arr); 11 Random number: Math.random (); generating decimals between 0~1 ; 12 random Number: parseint (Math.random () * (max-min+1) +min);
5, Date: Encapsulation operation time API, the number of milliseconds since January 1, 1970;
Create: ① Create Date object, automatically get client system time: var now=new date (), ② create Date object, and custom time: var date=new date ("Year/month/date hours:minutes:seconds") or var date=new date (year,month-1,date,hours,minutes,second); ③ copy Date object: var date2=new date (date1);
6. Date API:
① component: Fullyear,month,date,day (week), Hours,minutes,seconds,milliseconds;
② method: GetXXX: Gets the value of the specified component; Setxxx modifies the value of the specified component;
③ calculation: The date subtraction result is the number of milliseconds; Date.setxxx (Date.getxxx () +/-n);
④ to String:
Convert date to International standard date format: date.tostring ();
Converted to local time format: date.tolocalestring ();
Retention Date only: Date.tolocaledatestring ();
Retention time only: date.tolocaletimestring ();
This article reprint address:http://www.cnblogs.com/Jupiter258/
Javascript_core, Math, Date