Use for loop to initialize an array in JavaScript

var myarray = new Array();
for (i = 0; i < 10; i++)
{
    myarray[i] = i;
}
document.write(myarray);