Use for each loop to assign array element value in JavaScript

var myarray = new Array("","","","","","","","","","");
for (x in myarray)
{
    myarray[x] = "img" + x + ".gif";
}
document.write(myarray);