Saturday, November 15, 2025
HomeLanguagesJavascriptUnderscore.js _.iterators.List() Method

Underscore.js _.iterators.List() Method

With the help of _.iterators.List() method, we can get the iterator which when called up gives the next value of the List by using this method.

Syntax : 

_.iterators.List(array:Array)

Parameters value: This method accepts a single parameter as mentioned above and described below:

  • array: It holds the array where the method will be applied.

Return: Return the iterator for a List.

Example 1: In this example, we can see that by using _.iterators.List(array:Array) method, we are able to get the iterator which is invoked every time we call the iterator and return values of the List when called.

Javascript




// Defining underscore contrib variable 
var _ = require('underscore-contrib');
  
var gfg = _.iterators.List(["Geeks", "for", "Geeks"]);
  
for(var i = 0; i < 3; i++) {
    console.log(gfg());
}


Output :

Geeks
for
Geeks

Example 2 :

Javascript




// Defining underscore contrib variable 
var _ = require('underscore-contrib');
  
var gfg = _.iterators.List(["A", "B", "C", "D", "E"]);
  
for(var i = 0; i < 3; i++) {
    console.log(gfg());
}


Output :

A
B
C
D
E
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!
RELATED ARTICLES

Most Popular

Dominic
32399 POSTS0 COMMENTS
Milvus
95 POSTS0 COMMENTS
Nango Kala
6765 POSTS0 COMMENTS
Nicole Veronica
11917 POSTS0 COMMENTS
Nokonwaba Nkukhwana
11984 POSTS0 COMMENTS
Shaida Kate Naidoo
6890 POSTS0 COMMENTS
Ted Musemwa
7143 POSTS0 COMMENTS
Thapelo Manthata
6838 POSTS0 COMMENTS
Umr Jansen
6840 POSTS0 COMMENTS