File tree Expand file tree Collapse file tree 1 file changed +22
-1
lines changed Expand file tree Collapse file tree 1 file changed +22
-1
lines changed Original file line number Diff line number Diff line change @@ -478,6 +478,7 @@ items.isNotEmpty()
478
478
479
479
#### join
480
480
- *added in `1.0`*
481
+ - *updated in `4.2`*
481
482
482
483
The `join` method returns a string of all items concatenated. By default, it uses a comma `,` for concatenation:
483
484
@@ -493,10 +494,30 @@ You can provide a separator that will then be used for concatenation:
493
494
```js
494
495
const names = Arr.from([1, 2, 3])
495
496
496
- names.join()
497
+ names.join(' ; ' )
497
498
// ' 1 ; 2 ; 3 '
498
499
```
499
500
501
+ Since version `4.2` you can provide a second argument defining how to append the last item:
502
+
503
+ ```js
504
+ const names = Arr.from([1, 2, 3])
505
+
506
+ names.join(' , ' , ' , and' )
507
+ // ' 1 , 2 , and 3 '
508
+ ```
509
+
510
+ Since version `4.2` you may also provide a callback function that returns the value that will be joined into the resulting string value:
511
+
512
+ ```js
513
+ const names = Arr.from([1, 2, 3])
514
+
515
+ names.join((value, index, arr) => {
516
+ return `${value} --> `
517
+ })
518
+ // ' 1 --> 2 --> 3 --> '
519
+ ```
520
+
500
521
501
522
#### last
502
523
- *added in version `1.1`*
You can’t perform that action at this time.
0 commit comments