Thursday, September 4, 2025
HomeLanguagesJavascriptUnderscore.js _.iterators.drop() method

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




// Defining underscore contrib variable
const _ = require('underscore-contrib');
 
let iter = _.iterators.List(["Geeks", "for", "Geeks"]);
 
let geek = _.iterators.drop(iter, 2);
 
geek();


Output:

'Geeks'

Example 2:

javascript




// Defining underscore contrib variable
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'
Whether you’re preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape, neveropen Courses are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we’ve already empowered, and we’re here to do the same for you. Don’t miss out – check it out now!
Dominic
Dominichttp://wardslaus.com
infosec,malicious & dos attacks generator, boot rom exploit philanthropist , wild hacker , game developer,
RELATED ARTICLES

Most Popular

Dominic
32261 POSTS0 COMMENTS
Milvus
81 POSTS0 COMMENTS
Nango Kala
6626 POSTS0 COMMENTS
Nicole Veronica
11795 POSTS0 COMMENTS
Nokonwaba Nkukhwana
11855 POSTS0 COMMENTS
Shaida Kate Naidoo
6747 POSTS0 COMMENTS
Ted Musemwa
7023 POSTS0 COMMENTS
Thapelo Manthata
6695 POSTS0 COMMENTS
Umr Jansen
6714 POSTS0 COMMENTS