Skip to content

Merge

Merges array(s) of strings into a single string using a specified separator.

  • sep: string | boolean - The separator to use between merged strings.
    • Provide a string to use as a separator between strings.
    • Provide false or an empty string ('') for no separator.
    • Provide true for a space (' ') as the separator.
  • strings: string[] - The array of strings to merge.
  • The merged string.
Definition
function merge(
separator: boolean | string,
strings: string[] | string[][]): string
Examples
merge('-', 'Apple', 'Orange', 'Banana') // 'Apple-Orange-Banana'
merge(true, ['Banana', 'Orange', 'Apple', 'Mango']) // 'Banana Orange Apple Mango'
merge(false, ['1', '2', '3'], ['4', '5', '6']) // '123456'