79675380

Date: 2025-06-22 19:09:51
Score: 1.5
Natty:
Report link

The iterator object of the built-in iterable data types is itself iterable. (That is, it has a method with the symbolic name Symbol.iterator, which simply returns the object itself.) Sometimes this is useful in the following code when you want to run through a “partially used” iterator:

let list = [l,2,3,4,5];

let iter = list[Symbol.iterator]();

let head = iter.next().value; // head == 1

let tail = [...iter]; // tail == [2,3,4,5]

JavaScript: The Definitive Guide, David Flanagan, page 363

Reasons:
  • No code block (0.5):
  • Low reputation (1):
Posted by: Евгений Попов