How to Create a Month Name Array in JavaScript?

Estimated read time 1 min read

You can create a month name array in JavaScript using an array literal and the Array constructor. Here’s an example using the array literal:

var monthNames = ["January", "February", "March", "April", "May", "June",  "July", "August", "September", "October", "November", "December"];

And here’s an example using the Array constructor:

var monthNames = new Array("January", "February", "March", "April", "May", "June",
  "July", "August", "September", "October", "November", "December"

You can access individual elements of the array using square brackets and an index that starts at 0. For example, to access the name of the first month, you would use monthNames[0], which would return "January".

You May Also Like

More From Author

+ There are no comments

Add yours

Leave a Reply