Convert Javascript Array of Strings to Comma Separated - gecko-8/devwiki GitHub Wiki

Up

Use the Javascript array .join(separator) method

const result = myarray.join(',')

NOTE: The separator can be any string. E.g. .join(', ') will separate with a comma followed by a space.

If you have an array of objects and you want a comma (or any separator) separated string of one of the properties, do a map first.

const result = myarray.map(item => item.name).join(',');