default array values

arrays, javascript

Solution

Array.prototype.repeat= function(what, L){
 while(L) this[--L]= what;
 return this;
}

var A= [].repeat(0, 24);

alert(A)

Problem

Is there a way to assign a default values to arrays in javascript? ex: `an array with 24 slots that defaults to 0`

Original source