ran npm run build-list & add take.md

This commit is contained in:
King
2017-12-14 04:35:14 -05:00
parent f162c9bd01
commit 6aa980541b
2 changed files with 23 additions and 1 deletions

10
snippets/take.md Normal file
View File

@ -0,0 +1,10 @@
### Take
Use `.slice()` to create a slice of the array with n elements taken from the beginning.
```js
const take = (arr, n) => n === undefined ? arr.slice(0, 1) : arr.slice(0, n);
// take([1, 2, 3], 5) -> [1, 2, 3]
// take([1, 2, 3], 0) -> []
```