To declare a string array in JavaScript, you can use array literal syntax or the Array constructor with string elements.
In this example,
stringArray
using array literal syntax with predefined string values.const stringArray = ["Hello", "World", "JavaScript"];
console.log("String Array:", stringArray);
String Array: [ 'Hello', 'World', 'JavaScript' ]
In this example,
emptyStringArray
using the Array constructor without any elements.const emptyStringArray = new Array();
console.log("Empty String Array:", emptyStringArray);
Empty String Array: []
In this tutorial, we learned How to Declare a String Array in JavaScript language with well detailed examples.