|
Last change
on this file was a762898, checked in by istevanoska <ilinastevanoska@…>, 5 months ago |
|
Added visualizations
|
-
Property mode
set to
100644
|
|
File size:
583 bytes
|
| Line | |
|---|
| 1 | /**
|
|---|
| 2 | * Creates a slice of array with n elements taken from the beginning.
|
|---|
| 3 | *
|
|---|
| 4 | * @template T
|
|---|
| 5 | * @param {ArrayLike<T> | null | undefined} array - The array to query.
|
|---|
| 6 | * @param {number} [n=1] - The number of elements to take.
|
|---|
| 7 | * @returns {T[]} Returns the slice of array.
|
|---|
| 8 | *
|
|---|
| 9 | * @example
|
|---|
| 10 | * take([1, 2, 3]);
|
|---|
| 11 | * // => [1]
|
|---|
| 12 | *
|
|---|
| 13 | * @example
|
|---|
| 14 | * take([1, 2, 3], 2);
|
|---|
| 15 | * // => [1, 2]
|
|---|
| 16 | *
|
|---|
| 17 | * @example
|
|---|
| 18 | * take([1, 2, 3], 5);
|
|---|
| 19 | * // => [1, 2, 3]
|
|---|
| 20 | *
|
|---|
| 21 | * @example
|
|---|
| 22 | * take([1, 2, 3], 0);
|
|---|
| 23 | * // => []
|
|---|
| 24 | */
|
|---|
| 25 | declare function take<T>(array: ArrayLike<T> | null | undefined, n?: number): T[];
|
|---|
| 26 |
|
|---|
| 27 | export { take };
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.