Example: Writing out the current date and time using dense arrays
A dense array excels over a normal one when it comes to initializing a rather large array with values upon declaration. In this section, we'll create a script that writes out the current date and time, in the following format:
Tuesday, July 28, 2005
The tedious part is the definition of these text, and the perfect job for arrays to handle- dense arrays, to be precise:
var dayarray=new Array("Sunday","Monday","Tuesday", "Wednesday","Thursday","Friday","Saturday") var montharray=new Array("January","February","March","April","May", "June","July","August","September","October","November","December")
A code that may take a full page to write now has been reduced to one third, thanks to our buddy the dense array.