Lodash _.dropRight() Function
The _.dropRight() function is used to delete the elements from the right of the array i.e from the (n-1)th element.
- array: It is the original array from which elements are to be deleted.
- n: Here n is the number of elements that are to be deleted from the array. By default, it is set to one.
Return Value: It returns the array.
Note: Install the lodash module by using command
npm install lodash before using the code given below.
Example 1: When n is less than the size of an array.
Example 2: When n is greater than the size of the array.
Example 3: When an array of objects is given and n is not given.