One way could use recursion.
function fillArray(l, a) {
a = a || [];
if (0 < l) {
l -= 1;
a[l] = 0;
return fillArray(l, a);
}
return a;
}
I had also posted a more classic option:
function fillArray(l) {
var a;
for (a = []; 0 < l; l-=1, a[l]=0);
return a;
}