Format snippets
This commit is contained in:
@ -3,7 +3,7 @@ title: drop
|
||||
tags: array,beginner
|
||||
---
|
||||
|
||||
Returns a new array with `n` elements removed from the left.
|
||||
Creates a new array with `n` elements removed from the left.
|
||||
|
||||
- Use `Array.prototype.slice()` to remove the specified number of elements from the left.
|
||||
|
||||
@ -12,7 +12,7 @@ const drop = (arr, n = 1) => arr.slice(n);
|
||||
```
|
||||
|
||||
```js
|
||||
drop([1, 2, 3]); // [2,3]
|
||||
drop([1, 2, 3]); // [2, 3]
|
||||
drop([1, 2, 3], 2); // [3]
|
||||
drop([1, 2, 3], 42); // []
|
||||
```
|
||||
```
|
||||
|
||||
Reference in New Issue
Block a user