Skip to content

Commit 3296aa2

Browse files
committed
javascript-101/arrays: add info on second parameter of .slice()
Fixes jquerygh-611 Closes jquerygh-612
1 parent 7c3105e commit 3296aa2

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

page/javascript-101/arrays.md

+6
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,12 @@ console.log( myArray ); // [ 1, 2, 3, 4, 5, 6, 7, 8 ]
172172
console.log( newArray ); // [ 4, 5, 6, 7, 8 ]
173173
```
174174

175+
The `.slice()` method takes an optional second parameter, the end index.
176+
177+
```
178+
console.log( [ 1, 2, 3, 4, 5, 6, 7, 8 ].slice( 2, 5 ) ); // [ 3, 4, 5 ]
179+
```
180+
175181
### .splice()
176182

177183
Removes a certain amount of elements and adds new ones at the given index. It takes at least three parameters:

0 commit comments

Comments
 (0)