One, Date object
Format: Date Object name =new date ([date parameter])
Date parameters: 1. Omitted (most commonly used)
2. English-parameter format: month, year [time: seconds]
such as: Today=new Date ("October 1,2008 12:00:00");
3. Numerical format: Ad year, month, day, [Time, minute, second]
such as: Today=new Date (2008,10,1);
Copy Code code as follows:
<script type= "Text/javascript" >
var date=new date ();
var day=date.getday ();
if (day==0) {
Day= "Day";
}
document.write ("Now Moment:" + (Date.getyear () +1900) + "year" + (Date.getmonth () +1) + "month" +date.getdate () + "Day" + "Week" +day+ "" + Date.gethours () + ":" +date.getminutes () + ":" +date.getseconds ());
</script>
Two, Array object
To create an array object:
Format 1: Array object name =new array ([element number])
Format 2: Array object name =new array ([[element 1][, Element 2,...]])
Format 3: Array object name =[element 1[, Element 2,...]]
Array length variable, array element type can be different
such as: Fruit=new array (3);//fruit=new array ();
fruit[0]= "Apple";
fruit[1]= "Pear";
fruit[2]= "oranges";
Fruit=new Array ("Apple", "pear", "orange");
fruit=["Apple", "pear", "orange"];//use the most
Copy Code code as follows:
<script type= "Text/javascript" >
var fruits= new Array ("Apple", "pear", "orange");//More used
var fruits= ["Apple", "pear", "orange"];//recommend this to define, initialize the array, this way with the most
var fruits=new Array (4);//Less used
fruits[0]= "Apple";
fruits[1]= "Pear";
fruits[2]= "oranges";
fruits[3]= "Banana";
for (Var i=0;i<fruits.length;i++) {
Document.writeln ("fruit[" +i+ "]=" +fruits[i]+ "<br>");
}
</script>
Three or two-D array
Copy Code code as follows:
<script type= "Text/javascript" >
var fruits=new Array (3);
Fruits[0]=new Array ("Apple", 2);
Fruits[1]=new Array ("Pear", 3);
Fruits[2]=new Array ("Peach", 4);
for (Var i=0;i<fruits.length;i++) {
for (Var j=0;j<fruits[i].length;j++) {
Document.writeln ("fruits[" +i+ "] [" +j+ "]=" +fruits[i][j]+ "" </br> ");
}
Document.writeln ("</br>");
}
</script>