Add example of Array slice (#3823)

This commit is contained in:
Renjith VK
2018-06-12 20:06:06 +05:30
committed by John-David Dalton
parent b8dfb7cc14
commit 51c562256b

View File

@@ -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} [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`.
* @example
*
* var array = [1, 2, 3, 4]
*
* _.slice(array, 2)
* // => [3, 4]
*/
function slice(array, start, end) {
let length = array == null ? 0 : array.length