Time:
var time = new Date (); Get current time
var year = Time.getfullyear (); Year
var month = Time.getmouth () +1; Month
var day = Time.getday (); Weeks
var today = Time.getdate ();
Alert (XX); Can be directly output time
Mathematical functions:
var sx = Math.floor (); Take the whole number of parts
var sx = Math.ceil (); Take a decimal part
var sx = Math.Round (); Rounded
var sx = Math.max (x,x); Take maximum value
var rand = Math.random (); Defining a random array
Rand2 = parseint (RAND * 4)//rounding
var arr = [' 0 ', ' 1 ', ' 2 ', ' 3 ']; Convert to 1234
String:
var str = ' ABCDEFG ';
var index = str.indexof (' C '); Find the index value of the first C
var chars = Str.charat ();
var lastindex = str.lastindexof (' C '); Find the index value of the last C
Str.substring (1,3); Output BC
Str.substr (1,3); Starting from 1, the number of three, BCD
Str.replace (' abc ', ' 123 '); 123 instead of ABC, output 123
var up_str = Str.touppercase (); Convert to uppercase
Str.tolowcase ()//convert to lowercase
JS Basic function