How to create an array of strings in JavaScript?



To create an array of strings in JavaScript, simply assign values −

var animals = ["Time", "Money", "Work"];

You can also use the new keyword to create an array of strings in JavaScript −

var animals = new Array("Time", "Money", "Work");

The Array parameter is a list of strings or integers. When you specify a single numeric parameter with the Array constructor, you specify the initial length of the array. The maximum length allowed for an array is 4,294,967,295.

Example

Let’s see an example to create arrays in JavaScript −

Live Demo

    
         
      JavaScript Arrays    
           
         
                
   

Output

Returned string is : Money,Time,Work
Updated on: 2020-06-19T13:19:50+05:30

11K+ Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements