Iterator.prototype.next >= 0.1.2

Purpose

Return the next item

Syntax

Iterator#next ( );

Parameters

Return values

Object

Examples

Iterate over an array

var arr = ['a', 'b', 'c'],
    iter = new Iterator(arr);

iter.next();
>>> {index: 0, value: "a", done: false}

iter.next();
>>> {index: 1, value: "b", done: false}

iter.next();
>>> {index: 2, value: "c", done: false}

// There is no next item, so 'done' is true
iter.next();
>>> {done: true}

Iterate over an object

var obj = {a: 'x', b: 'y', c: 'z'},
    iter = new Iterator(obj);

iter.next();
>>> {index: 0, key: "a", value: "x", done: false}

iter.next();
>>> {index: 1, key: "b", value: "y", done: false}

iter.next();
>>> {index: 2, key: "c", value: "z", done: false}

iter.next();
>>> {done: true}

Comments

Courtney

Can you tell me what system are you making use of on this site?

Liliana

Do you have any type of suggestions for creating write-ups?

That's where I always struggle and also I just end up staring vacant screen for lengthy time.