To declare a string array in TypeScript, 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: string[] = ["Hello", "World", "TypeScript"];
console.log("String Array:", stringArray);
String Array: [ 'Hello', 'World', 'TypeScript' ]
In this example,
emptyStringArray
using the Array constructor without any elements.const emptyStringArray: string[] = new Array();
console.log("Empty String Array:", emptyStringArray);
Empty String Array: []
In this tutorial, we learned How to Declare a String Array in TypeScript language with well detailed examples.