Skip to main content

joinWith()

joinWith(strArr, joinChar): string

Joins an array of strings using the given character (see defaultJoinChar). When the given character appears in an array element, a backslash will be added just before it to distinguish it from the join character. Effectively the inverse of splitBy.

TIP: The join character can actually be a string of any length. Only the first character will be searched for in the array elements and preceded by a backslash.

Parameters

ParameterTypeDefault value
strArrany[]undefined
joinCharstringdefaultJoinChar

Returns

string

Example

joinWith(['this,,that', '', 'the other', '', '', ','], ', ')
// would return
'this\\,\\,that,,the other,,,\\,'

Defined in

packages/react-querybuilder/src/utils/arrayUtils.ts:46


caution

API documentation is generated from the latest commit on the main branch. It may be somewhat inconsistent with official releases of React Query Builder.