|
Last change
on this file was a762898, checked in by istevanoska <ilinastevanoska@…>, 5 months ago |
|
Added visualizations
|
-
Property mode
set to
100644
|
|
File size:
751 bytes
|
| Line | |
|---|
| 1 | /**
|
|---|
| 2 | * Returns a new array containing the last `count` elements from the input array `arr`.
|
|---|
| 3 | * If `count` is greater than the length of `arr`, the entire array is returned.
|
|---|
| 4 | *
|
|---|
| 5 | * @template T - The type of elements in the array.
|
|---|
| 6 | * @param {T[]} arr - The array to take elements from.
|
|---|
| 7 | * @param {number} [count=1] - The number of elements to take.
|
|---|
| 8 | * @returns {T[]} A new array containing the last `count` elements from `arr`.
|
|---|
| 9 | *
|
|---|
| 10 | * @example
|
|---|
| 11 | * // Returns [4, 5]
|
|---|
| 12 | * takeRight([1, 2, 3, 4, 5], 2);
|
|---|
| 13 | *
|
|---|
| 14 | * @example
|
|---|
| 15 | * // Returns ['b', 'c']
|
|---|
| 16 | * takeRight(['a', 'b', 'c'], 2);
|
|---|
| 17 | *
|
|---|
| 18 | * @example
|
|---|
| 19 | * // Returns [1, 2, 3]
|
|---|
| 20 | * takeRight([1, 2, 3], 5);
|
|---|
| 21 | */
|
|---|
| 22 | declare function takeRight<T>(arr: readonly T[], count?: number, guard?: unknown): T[];
|
|---|
| 23 |
|
|---|
| 24 | export { takeRight };
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.