Reverse loop array with iterables.
class IterableBackwards {
constructor(xs) {
this._xs = xs;
this._i = xs.length;
}
[Symbol.iterator]() { return this; }
next() {
return (this._i <= 0)
? { done: true, value: undefined }
: { done: false, value: this._xs[--this._i] };
}
}
const xs = ['A1', 'A2', 'A3'];
for (const x of new IterableBackwards(xs)) {
console.info(x);
}