VOOZH about

URL: https://www.geeksforgeeks.org/javascript/lodash-_-drop-method/

⇱ Lodash _.drop() Method - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

Lodash _.drop() Method

Last Updated : 30 Aug, 2024

Lodash _.drop() method is used to drop the elements in a given array.

Syntax:

_.drop(array, number);

Parameters:

  • Array: It is the original array from which the elements are to be removed.
  • Number: It is the number of elements to be removed from the array.

Note: The elements are removed from the index 0 of the array.

Return Value:

  • It returns the sliced array.

Example 1: In this example, we are dropping 2 elements of an array and printing the rest of the elements by the use of the _.drop() method.

Output:

👁 Image

Example 2: In this example, we are dropping 10 elements of an array and the number od dropping elements is higher than it's length so it will print the empty array.

Output:

👁 Image
Comment