array concat functionality added
This commit is contained in:
12
README.md
12
README.md
@ -21,6 +21,7 @@
|
|||||||
* [Check for palindrome](#check-for-palindrome)
|
* [Check for palindrome](#check-for-palindrome)
|
||||||
* [Chunk array](#chunk-array)
|
* [Chunk array](#chunk-array)
|
||||||
* [Compact](#compact)
|
* [Compact](#compact)
|
||||||
|
* [Concat](#concat)
|
||||||
* [Count occurrences of a value in array](#count-occurrences-of-a-value-in-array)
|
* [Count occurrences of a value in array](#count-occurrences-of-a-value-in-array)
|
||||||
* [Current URL](#current-url)
|
* [Current URL](#current-url)
|
||||||
* [Curry](#curry)
|
* [Curry](#curry)
|
||||||
@ -57,7 +58,7 @@
|
|||||||
* [Random integer in range](#random-integer-in-range)
|
* [Random integer in range](#random-integer-in-range)
|
||||||
* [Random number in range](#random-number-in-range)
|
* [Random number in range](#random-number-in-range)
|
||||||
* [Randomize order of array](#randomize-order-of-array)
|
* [Randomize order of array](#randomize-order-of-array)
|
||||||
* [Redirect to URL](#redirect-to-url)
|
* [Redirect to url](#redirect-to-url)
|
||||||
* [Reverse a string](#reverse-a-string)
|
* [Reverse a string](#reverse-a-string)
|
||||||
* [RGB to hexadecimal](#rgb-to-hexadecimal)
|
* [RGB to hexadecimal](#rgb-to-hexadecimal)
|
||||||
* [Run promises in series](#run-promises-in-series)
|
* [Run promises in series](#run-promises-in-series)
|
||||||
@ -206,6 +207,15 @@ const compact = (arr) => arr.filter(v => v);
|
|||||||
// compact([0, 1, false, 2, '', 3, 'a', 'e'*23, NaN, 's', 34]) -> [ 1, 2, 3, 'a', 's', 34 ]
|
// compact([0, 1, false, 2, '', 3, 'a', 'e'*23, NaN, 's', 34]) -> [ 1, 2, 3, 'a', 's', 34 ]
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### Concat
|
||||||
|
|
||||||
|
Creates a new array concatenating array with any additional arrays and/or values `args` using `Array.concat()`.
|
||||||
|
|
||||||
|
```js
|
||||||
|
const ArrayConcat = (arr, ...args) => arr.concat(...args);
|
||||||
|
// ArrayConcat([1], [1, 2, 3, [4]]) -> [1, 2, 3, [4]]
|
||||||
|
```
|
||||||
|
|
||||||
### Count occurrences of a value in array
|
### Count occurrences of a value in array
|
||||||
|
|
||||||
Use `Array.reduce()` to increment a counter each time you encounter the specific value inside the array.
|
Use `Array.reduce()` to increment a counter each time you encounter the specific value inside the array.
|
||||||
|
|||||||
8
snippets/concat.md
Normal file
8
snippets/concat.md
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
### Concat
|
||||||
|
|
||||||
|
Creates a new array concatenating array with any additional arrays and/or values `args` using `Array.concat()`.
|
||||||
|
|
||||||
|
```js
|
||||||
|
const ArrayConcat = (arr, ...args) => arr.concat(...args);
|
||||||
|
// ArrayConcat([1], [1, 2, 3, [4]]) -> [1, 2, 3, [4]]
|
||||||
|
```
|
||||||
Reference in New Issue
Block a user