Iterators in JavaScript and remembering position
How about the following recursive approach



function link(list) {
    if(!list.length)
        return [];

    let [car, ...cdr] = list;
    return {
        car,
        cdr: link(cdr),
        [Symbol.iterator]: function*() {
            yield this;
            yield *this.cdr;
        }
    }
}

ls = link([1, 2, 3, 4])

for (let t of ls)
    console.log(t.car)