MarkLogic 9 Product Documentation
Sequence.prototype.@@iterator

Sequence.prototype.@@iterator() as Object

Summary

Return an iterator object. A Sequence is flattened when iterated through. Advancing the returned iterator does not side-effect the Sequence.

Example

const docs = fn.doc();
let i = 0;
for (const doc of docs) i++;
for (const doc of docs) i++;
i;

// Returns 2 * the number of documents

Example

const s = Sequence.from("javascript", x=>x.toUpperCase());
const it = s[Symbol.iterator]();
[s, it.next().value];

// Returns: [["J", "A", "V", "A", "S", "C", "R", "I", "P", "T"], "J"]
Powered by MarkLogic Server | Terms of Use | Privacy Policy