Lodash _.dropRightWhile() Function
The _.dropRightWhile() function is used to delete the slice of the array excluding elements dropped from the end until the predicate function returns false.
- array: It is the array from which the elements are to be removed.
- predicate: It is the function that iterates over each element of the array and returns true or false on the basis of the condition given.
Return: It returns the array.
Note: Install the lodash module by using the command
npm install lodash before using the code given below.
Example 2: In this example, the predicate function returns false it does not check further and returns the sliced array. Please note that it is different from drop while as it drops element from the right side and not left.