Syntax 1
ArrayName = new Array();
ArrayName [0] ="value1";
ArrayName [1] ="value2";
...
ArrayName [N] ="valueN";
Syntax 2
ArrayName = new Array( value1",value2" ... ,valueN");
Syntax 3
ArrayName = [value1",value2" ... ,valueN"];
Retrieve Value 1
ArrayName = ArrayName[0];
ArrayName += ArrayName[1];
...
ArrayName += ArrayName[N];
Retrieve Value 2
for (variableName in ArrayName ) {
ArrayName[variableName];
}
Example with Date
<script language="JavaScript">
var DayName = new Array("Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday");
var d = new Date();
var output = "Today is " + DayName[d.getDay()] + " ";
output += d.getDate()+ "/";
output += (d.getMonth() + 1) + "/";
output += d.getYear() + " ";
output += d.getHours() + ":";
output += d.getMinutes() + ":";
output += d.getSeconds();
document.write(output);
</script>
figure 1 : Sample with Date
##############################
No comments:
Post a Comment