EN
TypeScript - convert array to string
0 points
In this article, we would like to show you how to convert an array to string in TypeScript.
In this example, we use toString()
method to convert the letters
array to string.
xxxxxxxxxx
1
const letters: string[] = ['A', 'B', 'C'];
2
const result: string = letters.toString();
3
4
console.log(result);
Output:
xxxxxxxxxx
1
A,B,C
In this example, we use join()
method to convert the letters
array to string.
xxxxxxxxxx
1
const letters: string[] = ['A', 'B', 'C'];
2
const result: string = letters.join('');
3
4
console.log(result);
Output:
xxxxxxxxxx
1
ABC