![]() |
VOOZH | about |
Lodash _.takeRight() method is used to get the array of n elements from the end of the given array.
_.takeRight(array, n);Example 1: In this example, we are getting an array that has only one element.
Output:
[7]Example 2: In this example, we are getting an array that has five elements.
Output:
[ 3, 4, 5, 6, 7 ]Example 3: In this example, we are getting an array that has no element.
Output:
[]Note: This will not work in normal JavaScript because it requires the library lodash to be installed.