try

array.reduce( (s,x,i) => s+(i>0 ? separator : '') + (x==null ? '' : x), '') 

function myJoin(array, separator=',') { 
  return array.reduce( (s,x,i) => s+(i>0 ? separator : '') + (x==null ? '' : x), '') 
}

console.log( myJoin(['a', 'b', 'c'], '+') ); 
console.log( myJoin(['Peter', 'Paul', 'Mary']) );
console.log( myJoin(['hello', undefined, 'world'], '-') );

We use here standard js functionalities: arrow functions, array reduce and ternary operator. If i>0 (not true only for first element) we add separator to output string s. If x is undefined or null we add to s empty string - or x value in other case.

Answer from Kamil Kieล‚czewski on Stack Overflow
๐ŸŒ
TutorialsPoint
tutorialspoint.com โ€บ typescript โ€บ typescript_array_join.htm
TypeScript - Array join()
join() method joins all the elements of an array into a string. separator โˆ’ Specifies a string to separate each element of the array. If omitted, the array elements are separated with a comma.
๐ŸŒ
SPGuides
spguides.com โ€บ typescript-array-to-string-with-separator
How to Convert Typescript Array to String With Separator?
July 21, 2025 - Learn how to convert a TypeScript array to a string with a custom separator. Step-by-step guide with examples to join array elements efficiently.
๐ŸŒ
MDN Web Docs
developer.mozilla.org โ€บ en-US โ€บ docs โ€บ Web โ€บ JavaScript โ€บ Reference โ€บ Global_Objects โ€บ Array โ€บ join
Array.prototype.join() - JavaScript - MDN Web Docs
Because the string returned by Array.prototype.toString (which is the same as calling join()) does not have delimiters, nested arrays look like they are flattened. You can only control the separator of the first level, while deeper levels always use the default comma.
๐ŸŒ
Reddit
reddit.com โ€บ r/javascripttips โ€บ how do i convert an array to a string with commas in javascript
r/JavaScriptTips on Reddit: How do I convert an array to a string with commas in JavaScript
April 13, 2023 -

In JavaScript, you can convert an array to a string with commas using the join()
method.

The join() method returns a string that concatenates all the elements of an array, separated by the specified separator, which in this case is a comma.

Here is an example:

const array = ['apple', 'banana', 'orange'];
const string = array.join(', ');
console.log(string); 

// output: "apple, banana, orange"

In this example, we first define an array of three fruits. Then we use the join()
method with a comma and a space as the separator to create a string that lists all the fruits with a comma and a space between each one.

You can replace the comma and space separator with any other separator you like, such as a hyphen, a semicolon, or a newline character.

It's important to note that the join() method only works on arrays, and it will throw an error if you try to use it on any other type of object.

Click here to learn more ways to Convert Array to String with Commas in JS

๐ŸŒ
xjavascript
xjavascript.com โ€บ blog โ€บ typescript-array-to-string-with-separator
TypeScript Array to String with Separator: A Comprehensive Guide โ€” xjavascript.com
In JavaScript (and thus TypeScript), the join() method is used for this purpose. The join() method creates and returns a new string by concatenating all of the elements in an array, separated by a specified separator string.
๐ŸŒ
Webdevtutor
webdevtutor.net โ€บ blog โ€บ typescript-array-of-objects-to-string-with-separator
Converting TypeScript Array of Objects to String with Separator
interface Person { name: string; ... objects and specify a separator as ', '. We then use the map() method to transform each object into a formatted string and finally join these strings using the specified separator....
Find elsewhere
๐ŸŒ
Webdevtutor
webdevtutor.net โ€บ blog โ€บ typescript-array-to-string-separator
Converting TypeScript Array to String with Separator
The join method concatenates all the elements of an array into a single string, separated by the specified separator.
๐ŸŒ
GeeksforGeeks
geeksforgeeks.org โ€บ typescript-array-join-method
TypeScript Array join() Method - GeeksforGeeks
July 12, 2024 - The Array.join() method in TypeScript is a built-in function used to join all the elements of an array into a single string. This method is particularly useful when you need to concatenate array elements with a specific separator.
๐ŸŒ
Educative
educative.io โ€บ answers โ€บ what-is-the-join-method-of-an-array-in-typescript
What is the join() method of an array in TypeScript?
... separator: This is a character or string that separates each element of the array when joined as a string. This method returns the combination of all the elements of the array as a single string.
๐ŸŒ
ReqBin
reqbin.com โ€บ code โ€บ javascript โ€บ ot8wzla9 โ€บ javascript-array-to-string-example
How do I convert array to string in JavaScript?
November 21, 2023 - To convert an array to a string using a separator between elements in JavaScript, you can use the array.join(separator) method: JavaScript Convert Array to String with Separator Example
๐ŸŒ
DEV Community
dev.to โ€บ mehmehmehlol โ€บ from-string-to-array-to-string-f67
From String to Array to String - DEV Community
April 23, 2021 - By default the elements are separated by commas, however you can specify what you want to join/separate the elements by. On the other hand, if there is only one element in the array, the single item will be returned as a string without separators, and if there are no elements, an empty string is returned.
๐ŸŒ
xjavascript
xjavascript.com โ€บ blog โ€บ typescript-array-tostring
Mastering TypeScript Array `toString()`: A Comprehensive Guide
The toString() method in TypeScript arrays is inherited from the JavaScript Array.prototype.toString(). When you call the toString() method on an array, it converts each element of the array to a string and then concatenates these strings, ...
๐ŸŒ
DEV Community
dev.to โ€บ gaelgthomas โ€บ array-to-string-without-commas-in-javascript-4mg6
Array to String Without Commas in JavaScript - DEV Community
September 18, 2022 - with parameter: your array will ... If you want to join your array with something different than commas, you can pass the separator of your choice....
๐ŸŒ
Webdevtutor
webdevtutor.net โ€บ blog โ€บ typescript-array-of-strings-to-comma-separated-string
Converting TypeScript Array of Strings to Comma-Separated String
The most straightforward way to convert an array of strings to a comma-separated string in TypeScript is by using the Array.join() method.
๐ŸŒ
Webdevtutor
webdevtutor.net โ€บ blog โ€บ typescript-array-as-string
Converting TypeScript Array to String: A Comprehensive Guide
One of the simplest ways to convert a TypeScript array to a string is by using the join() method. This method concatenates all the elements of an array into a string, with an optional separator between each element.
๐ŸŒ
Altcademy
altcademy.com โ€บ blog โ€บ how-to-convert-array-to-string-in-javascript
How to convert array to string in JavaScript - Altcademy.com
August 29, 2023 - You may be asking, "What is the difference between toString() and join()?" The primary difference is that toString() does not allow you to specify a custom separator. toString() will always separate array elements with a comma, while join() allows for custom separators. What happens when we have an array within an array, also known as a nested array? Can we convert that to a string too?