![]() |
VOOZH | about |
Lodash _.dropRight() function is used to delete the elements from the right of the array i.e from the (n-1)th element.
_.dropRight(array, n);Note:
Install the lodash module by using command
npm install lodashbefore using the code given below.
Example 1: In this example, we are printing the new array having two elements less from the right side of the original array.
Output:
👁 ImageExample 2: In this example, given value is greater than the length of the given array so it is giving empty array.
Output:
👁 ImageExample 3: In this example, we are printing the new array having one element less from the right side of the original array.