mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-07 10:07:48 +00:00
Add example of Array slice (#3823)
This commit is contained in:
committed by
John-David Dalton
parent
b8dfb7cc14
commit
51c562256b
6
slice.js
6
slice.js
@@ -11,6 +11,12 @@
|
|||||||
* @param {number} [start=0] The start position. A negative index will be treated as an offset from the end.
|
* @param {number} [start=0] The start position. A negative index will be treated as an offset from the end.
|
||||||
* @param {number} [end=array.length] The end position. A negative index will be treated as an offset from the end.
|
* @param {number} [end=array.length] The end position. A negative index will be treated as an offset from the end.
|
||||||
* @returns {Array} Returns the slice of `array`.
|
* @returns {Array} Returns the slice of `array`.
|
||||||
|
* @example
|
||||||
|
*
|
||||||
|
* var array = [1, 2, 3, 4]
|
||||||
|
*
|
||||||
|
* _.slice(array, 2)
|
||||||
|
* // => [3, 4]
|
||||||
*/
|
*/
|
||||||
function slice(array, start, end) {
|
function slice(array, start, end) {
|
||||||
let length = array == null ? 0 : array.length
|
let length = array == null ? 0 : array.length
|
||||||
|
|||||||
Reference in New Issue
Block a user