Underscore.js _.iterators.drop() method
With the help of _.iterators.drop() method, we can get the values whenever we call the iterator but drops the values till the numberToDrop value and return the generated value by using this method.
Syntax:
_.iterators.drop(iter, numberToDrop)
Return: Return the values by the iterator after dropping certain values.
Example 1: In this method, we can see that by using _.iterators.drop() method, we are able to get the value whenever the iterator is called but drop some values till the numberToDrop value.
javascript
const _ = require( 'underscore-contrib' );
let iter = _.iterators.List([ "Geeks" , "for" , "Geeks" ]);
let geek = _.iterators.drop(iter, 2);
geek();
|
Output:
'Geeks'
Example 2:
javascript
const _ = require( 'underscore-contrib' );
let iter = _.iterators.List([ "E" , "D" , "C" , "B" , "A" ]);
let geek = _.iterators.drop(iter, 2);
geek();
geek();
geek();
|
Output:
'C'
'B'
'A'
Last Updated :
11 Apr, 2023
Like Article
Save Article
Share your thoughts in the comments
Please Login to comment...