- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
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 −
<html> <head> <title>JavaScript Arrays</title> </head> <body> <script> var arr = new Array("Time","Money","Work"); var sorted = arr.sort(); document.write("Returned string is : " + sorted ); </script> </body> </html>
Output
Returned string is : Money,Time,Work
- Related Articles
- How to create array of strings in Java?
- How to create an array of integers in JavaScript?
- How to convert array of decimal strings to array of integer strings without decimal in JavaScript
- How to convert array of strings to array of numbers in JavaScript?
- How can I convert an array to an object by splitting strings? JavaScript
- How to dynamically create radio buttons using an array in JavaScript?
- JavaScript filter an array of strings, matching case insensitive substring?
- How to create a string by joining the elements of an array in JavaScript?
- Finding all the longest strings from an array in JavaScript
- Removing consecutive duplicates from strings in an array using JavaScript
- How to trim all strings in an array in PHP ?
- How to create an array of Object in Java
- How to create an array of objects in TypeScript?
- How to create an array in PowerShell?
- How to create an Array in Java?

Advertisements