join() : Join Array with Separator
On this page
Summary
Join array elements into a single string with a separator.
Signature
join(array, separator)
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
array |
Array | Yes | The array to join |
separator |
String | Yes | The separator to use between elements |
Returns
Type: String
A single string with all array elements joined by the separator.
Examples
Comma-Separated List
Data:
doc.Params["model"] = new {
tags = new[] { "JavaScript", "HTML", "CSS", "React" }
};
Output:
<p>Tags: JavaScript, HTML, CSS, React</p>
Pipe-Separated Values
Data:
doc.Params["model"] = new {
categories = new[] { "Electronics", "Computers", "Accessories" }
};
Output:
<p>Categories: Electronics | Computers | Accessories</p>
Create Full Name
Data:
doc.Params["model"] = new {
nameParts = new[] { "John", "Q", "Doe" }
};
Output:
<p>Name: John Q Doe</p>
Bullet List
Data:
doc.Params["model"] = new {
features = new[] { "Fast", "Reliable", "Secure", "Scalable" }
};
Output:
<p>Features: Fast • Reliable • Secure • Scalable</p>
Create Path
Data:
doc.Params["model"] = new {
pathParts = new[] { "home", "user", "documents", "file.txt" }
};
Output:
<p>Path: home/user/documents/file.txt</p>
Notes
- Works with string arrays
- Non-string array elements are converted to strings
- Empty arrays return empty string
- Null elements are treated as empty strings
- For collection of objects, use with
collect()to extract property first - Alternative to manually iterating with ``