default array values

Is there a way to assign a default values to arrays in javascript?

ex: an array with 24 slots that defaults to 0

Answers


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

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

alert(A)


var a = Array.apply(null, Array(24)).map(function() { return 0 });

// or:
var a = Array.apply(null, Array(5)).map(Boolean).map(Number);

Need Your Help

Regex: C# method declaration parsing

c# regex

Could somebody help me parse following from the C# method declaration: scope, isStatic, name, return type and list of the parameters and their types. So given method declaration like this

how to login in magento admin using coding

magento-1.7

Hi magento geeks i need your help,

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.