The drop()
function of the Underscore library in JavaScript is used to remove the first n
elements from an array and return the remaining elements in a new array.
Here's an example of how to use drop()
:
index.tsx147 chars8 lines
In the example above, we first import the Underscore library using the require()
function, and define an array arr
and the number of elements to remove n
.
We then call the _.drop()
function with arr
and n
as arguments, and store the result in the result
variable.
Finally, we log the result
to the console, which outputs [4, 5]
as the first three elements of arr
have been removed.
gistlibby LogSnag