You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
22 lines
432 B
22 lines
432 B
4 years ago
|
# `join()`
|
||
|
|
||
|
The join method joins the collection's values with a string:
|
||
|
|
||
|
```js
|
||
|
collect(['a', 'b', 'c']).join(', ');
|
||
|
// 'a, b, c'
|
||
|
|
||
|
collect(['a', 'b', 'c']).join(', ', ', and ');
|
||
|
// 'a, b, and c'
|
||
|
|
||
|
collect(['a', 'b']).join(', ', ' and ');
|
||
|
// 'a and b'
|
||
|
|
||
|
collect(['a']).join(', ', ' and ');
|
||
|
// 'a'
|
||
|
|
||
|
collect([]).join(', ', ' and ');
|
||
|
// ''
|
||
|
```
|
||
|
|
||
|
[View source on GitHub](https://github.com/ecrmnn/collect.js/blob/master/src/methods/join.js)
|